math.sin on complex, imaginary part

Percentage Accurate: 54.0% → 99.8%
Time: 18.4s
Alternatives: 15
Speedup: 14.6×

Specification

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

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - 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 15 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: 54.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -0.4) (not (<= t_0 5e-5)))
     (* (* 0.5 (cos re)) t_0)
     (- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* im (cos re))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (im * cos(re));
	}
	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 = exp(-im) - exp(im)
    if ((t_0 <= (-0.4d0)) .or. (.not. (t_0 <= 5d-5))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = ((-0.16666666666666666d0) * (cos(re) * (im ** 3.0d0))) - (im * cos(re))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (im * Math.cos(re));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -0.4) or not (t_0 <= 5e-5):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (im * math.cos(re))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - Float64(im * cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -0.4) || ~((t_0 <= 5e-5)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (im * cos(re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.4], N[Not[LessEqual[t$95$0, 5e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.40000000000000002 or 5.00000000000000024e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

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

    if -0.40000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.00000000000000024e-5

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub07.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -0.4 \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\ \end{array} \]

Alternative 2: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -0.4) (not (<= t_0 5e-5)))
     (* (* 0.5 (cos re)) t_0)
     (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-0.4d0)) .or. (.not. (t_0 <= 5d-5))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -0.4) or not (t_0 <= 5e-5):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -0.4) || !(t_0 <= 5e-5))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -0.4) || ~((t_0 <= 5e-5)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.4], N[Not[LessEqual[t$95$0, 5e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.40000000000000002 or 5.00000000000000024e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

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

    if -0.40000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.00000000000000024e-5

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub07.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg99.8%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg99.8%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative99.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -0.4 \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]

Alternative 3: 95.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+111} \lor \neg \left(im \leq -0.022 \lor \neg \left(im \leq 0.06\right) \land im \leq 6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -4.5e+111)
         (not (or (<= im -0.022) (and (not (<= im 0.06)) (<= im 6e+102)))))
   (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
   (* (- (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))))
double code(double re, double im) {
	double tmp;
	if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102)))) {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	} else {
		tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-4.5d+111)) .or. (.not. (im <= (-0.022d0)) .or. (.not. (im <= 0.06d0)) .and. (im <= 6d+102))) then
        tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    else
        tmp = (exp(-im) - exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102)))) {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	} else {
		tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -4.5e+111) or not ((im <= -0.022) or (not (im <= 0.06) and (im <= 6e+102))):
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	else:
		tmp = (math.exp(-im) - math.exp(im)) * (0.5 + (-0.25 * (re * re)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102))))
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	else
		tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -4.5e+111) || ~(((im <= -0.022) || (~((im <= 0.06)) && (im <= 6e+102)))))
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	else
		tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -4.5e+111], N[Not[Or[LessEqual[im, -0.022], And[N[Not[LessEqual[im, 0.06]], $MachinePrecision], LessEqual[im, 6e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.5 \cdot 10^{+111} \lor \neg \left(im \leq -0.022 \lor \neg \left(im \leq 0.06\right) \land im \leq 6 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -4.50000000000000001e111 or -0.021999999999999999 < im < 0.059999999999999998 or 5.9999999999999996e102 < im

    1. Initial program 41.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub041.8%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified41.8%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.9%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg99.9%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg99.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--99.9%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative99.9%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]

    if -4.50000000000000001e111 < im < -0.021999999999999999 or 0.059999999999999998 < im < 5.9999999999999996e102

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 6.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+111} \lor \neg \left(im \leq -0.022 \lor \neg \left(im \leq 0.06\right) \land im \leq 6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

Alternative 4: 95.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+102} \lor \neg \left(im \leq -0.0155\right) \land \left(im \leq 0.024 \lor \neg \left(im \leq 2.7 \cdot 10^{+99}\right)\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -5.5e+102)
         (and (not (<= im -0.0155)) (or (<= im 0.024) (not (<= im 2.7e+99)))))
   (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
   (* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99)))) {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	} else {
		tmp = 0.5 * (exp(-im) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-5.5d+102)) .or. (.not. (im <= (-0.0155d0))) .and. (im <= 0.024d0) .or. (.not. (im <= 2.7d+99))) then
        tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    else
        tmp = 0.5d0 * (exp(-im) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99)))) {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	} else {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -5.5e+102) or (not (im <= -0.0155) and ((im <= 0.024) or not (im <= 2.7e+99))):
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	else:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99))))
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	else
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -5.5e+102) || (~((im <= -0.0155)) && ((im <= 0.024) || ~((im <= 2.7e+99)))))
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	else
		tmp = 0.5 * (exp(-im) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -5.5e+102], And[N[Not[LessEqual[im, -0.0155]], $MachinePrecision], Or[LessEqual[im, 0.024], N[Not[LessEqual[im, 2.7e+99]], $MachinePrecision]]]], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+102} \lor \neg \left(im \leq -0.0155\right) \land \left(im \leq 0.024 \lor \neg \left(im \leq 2.7 \cdot 10^{+99}\right)\right):\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.49999999999999981e102 or -0.0155 < im < 0.024 or 2.69999999999999989e99 < im

    1. Initial program 43.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub043.2%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified43.2%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.5%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. +-commutative99.5%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg99.5%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg99.5%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*99.5%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--99.5%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative99.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified99.5%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]

    if -5.49999999999999981e102 < im < -0.0155 or 0.024 < im < 2.69999999999999989e99

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 72.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+102} \lor \neg \left(im \leq -0.0155\right) \land \left(im \leq 0.024 \lor \neg \left(im \leq 2.7 \cdot 10^{+99}\right)\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 5: 84.9% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{if}\;im \leq -1.5 \cdot 10^{+103}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.00011:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 0.0012:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+51}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+133}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.5e103 or 6.5e51 < im < 1.79999999999999989e133

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 90.2%

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

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg90.2%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg90.2%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*90.2%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--90.2%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative90.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified90.2%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 7.3%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+7.3%

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in82.7%

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

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + 1\right)} \]
      5. *-inverses82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + \color{blue}{\frac{e^{\cos re}}{e^{\cos re}}}\right) \]
      6. +-commutative82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \color{blue}{\left(\frac{e^{\cos re}}{e^{\cos re}} + -0.5 \cdot {re}^{2}\right)} \]
      7. *-inverses82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(\color{blue}{1} + -0.5 \cdot {re}^{2}\right) \]
      8. unpow282.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + -0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      9. associate-*r*82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) \]
      10. *-commutative82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right) \]
      11. *-commutative82.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \color{blue}{\left(re \cdot -0.5\right)}\right) \]
    9. Simplified82.7%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)} \]
    10. Step-by-step derivation
      1. sub-neg82.7%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      2. *-commutative82.7%

        \[\leadsto \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      3. unpow382.7%

        \[\leadsto \left(\color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} \cdot -0.16666666666666666 + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      4. associate-*l*82.7%

        \[\leadsto \left(\color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      5. fma-def82.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
    12. Step-by-step derivation
      1. fma-udef82.7%

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

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

    if -1.5e103 < im < -1.10000000000000004e-4 or 0.00119999999999999989 < im < 6.5e51

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 76.9%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right)} \]

    if -1.10000000000000004e-4 < im < 0.00119999999999999989

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub07.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.6%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*99.6%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
      2. neg-mul-199.6%

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified99.6%

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

    if 1.79999999999999989e133 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Taylor expanded in re around 0 90.0%

      \[\leadsto \color{blue}{-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}} \]
    6. Step-by-step derivation
      1. +-commutative90.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im} \]
      2. neg-mul-190.0%

        \[\leadsto -0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)} \]
      3. sub-neg90.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    7. Simplified90.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification91.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.5 \cdot 10^{+103}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{elif}\;im \leq -0.00011:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.0012:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+51}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+133}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 6: 77.3% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.2 \cdot 10^{+15} \lor \neg \left(im \leq 4.8 \cdot 10^{-20}\right):\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.2e15 or 4.79999999999999986e-20 < im

    1. Initial program 99.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.2%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.2%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 67.9%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. +-commutative67.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg67.9%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg67.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*67.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--67.9%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative67.9%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified67.9%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 9.0%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+9.0%

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in63.4%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. *-commutative63.4%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + 1\right)} \]
      5. *-inverses63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + \color{blue}{\frac{e^{\cos re}}{e^{\cos re}}}\right) \]
      6. +-commutative63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \color{blue}{\left(\frac{e^{\cos re}}{e^{\cos re}} + -0.5 \cdot {re}^{2}\right)} \]
      7. *-inverses63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(\color{blue}{1} + -0.5 \cdot {re}^{2}\right) \]
      8. unpow263.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + -0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      9. associate-*r*63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) \]
      10. *-commutative63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right) \]
      11. *-commutative63.4%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \color{blue}{\left(re \cdot -0.5\right)}\right) \]
    9. Simplified63.4%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)} \]
    10. Step-by-step derivation
      1. sub-neg63.4%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      2. *-commutative63.4%

        \[\leadsto \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      3. unpow363.4%

        \[\leadsto \left(\color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} \cdot -0.16666666666666666 + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      4. associate-*l*63.4%

        \[\leadsto \left(\color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      5. fma-def63.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
    11. Applied egg-rr63.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
    12. Step-by-step derivation
      1. fma-udef63.4%

        \[\leadsto \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) + \left(-im\right)\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
    13. Applied egg-rr63.4%

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

    if -6.2e15 < im < 4.79999999999999986e-20

    1. Initial program 8.7%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub08.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified8.7%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 98.1%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.1%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
      2. neg-mul-198.1%

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified98.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.2 \cdot 10^{+15} \lor \neg \left(im \leq 4.8 \cdot 10^{-20}\right):\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \]

Alternative 7: 44.4% accurate, 14.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(0.5 \cdot re\right)\\ t_1 := \frac{im \cdot im}{im \cdot \left(-1 - t_0\right)}\\ \mathbf{if}\;im \leq -1.3 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -7.2 \cdot 10^{+19}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+155}:\\ \;\;\;\;\left(im + 1.1666666666666667\right) \cdot \left(-1 + t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (* 0.5 re))) (t_1 (/ (* im im) (* im (- -1.0 t_0)))))
   (if (<= im -1.3e+170)
     t_1
     (if (<= im -7.2e+19)
       (- (* im (* 0.5 (* re re))) im)
       (if (<= im 1.4)
         (- im)
         (if (<= im 1.6e+155)
           (* (+ im 1.1666666666666667) (+ -1.0 t_0))
           t_1))))))
double code(double re, double im) {
	double t_0 = re * (0.5 * re);
	double t_1 = (im * im) / (im * (-1.0 - t_0));
	double tmp;
	if (im <= -1.3e+170) {
		tmp = t_1;
	} else if (im <= -7.2e+19) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 1.4) {
		tmp = -im;
	} else if (im <= 1.6e+155) {
		tmp = (im + 1.1666666666666667) * (-1.0 + t_0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = re * (0.5d0 * re)
    t_1 = (im * im) / (im * ((-1.0d0) - t_0))
    if (im <= (-1.3d+170)) then
        tmp = t_1
    else if (im <= (-7.2d+19)) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else if (im <= 1.4d0) then
        tmp = -im
    else if (im <= 1.6d+155) then
        tmp = (im + 1.1666666666666667d0) * ((-1.0d0) + t_0)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * (0.5 * re);
	double t_1 = (im * im) / (im * (-1.0 - t_0));
	double tmp;
	if (im <= -1.3e+170) {
		tmp = t_1;
	} else if (im <= -7.2e+19) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 1.4) {
		tmp = -im;
	} else if (im <= 1.6e+155) {
		tmp = (im + 1.1666666666666667) * (-1.0 + t_0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (0.5 * re)
	t_1 = (im * im) / (im * (-1.0 - t_0))
	tmp = 0
	if im <= -1.3e+170:
		tmp = t_1
	elif im <= -7.2e+19:
		tmp = (im * (0.5 * (re * re))) - im
	elif im <= 1.4:
		tmp = -im
	elif im <= 1.6e+155:
		tmp = (im + 1.1666666666666667) * (-1.0 + t_0)
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(0.5 * re))
	t_1 = Float64(Float64(im * im) / Float64(im * Float64(-1.0 - t_0)))
	tmp = 0.0
	if (im <= -1.3e+170)
		tmp = t_1;
	elseif (im <= -7.2e+19)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	elseif (im <= 1.4)
		tmp = Float64(-im);
	elseif (im <= 1.6e+155)
		tmp = Float64(Float64(im + 1.1666666666666667) * Float64(-1.0 + t_0));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (0.5 * re);
	t_1 = (im * im) / (im * (-1.0 - t_0));
	tmp = 0.0;
	if (im <= -1.3e+170)
		tmp = t_1;
	elseif (im <= -7.2e+19)
		tmp = (im * (0.5 * (re * re))) - im;
	elseif (im <= 1.4)
		tmp = -im;
	elseif (im <= 1.6e+155)
		tmp = (im + 1.1666666666666667) * (-1.0 + t_0);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * im), $MachinePrecision] / N[(im * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+170], t$95$1, If[LessEqual[im, -7.2e+19], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.4], (-im), If[LessEqual[im, 1.6e+155], N[(N[(im + 1.1666666666666667), $MachinePrecision] * N[(-1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot re\right)\\
t_1 := \frac{im \cdot im}{im \cdot \left(-1 - t_0\right)}\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+170}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 1.4:\\
\;\;\;\;-im\\

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+155}:\\
\;\;\;\;\left(im + 1.1666666666666667\right) \cdot \left(-1 + t_0\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.2999999999999999e170 or 1.60000000000000006e155 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(-2 \cdot im\right) \cdot 0.5\right) \cdot \left(\left(-2 \cdot im\right) \cdot 0.5\right) - \left(\left(-2 \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}{\left(-2 \cdot im\right) \cdot 0.5 - \left(-2 \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)}} \]
    9. Applied egg-rr57.4%

      \[\leadsto \color{blue}{\frac{\left(-im\right) \cdot \left(-im\right) - \left(im \cdot \left(-2 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)\right) \cdot \left(im \cdot \left(-2 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)\right)}{\left(-im\right) - im \cdot \left(-2 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. Simplified75.9%

        \[\leadsto \color{blue}{\frac{im \cdot \left(im - re \cdot \left(\left(re \cdot 0.5\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)\right)\right)}{im \cdot \left(-1 - re \cdot \left(re \cdot 0.5\right)\right)}} \]
      2. Taylor expanded in re around 0 70.4%

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

          \[\leadsto \frac{\color{blue}{im \cdot im}}{im \cdot \left(-1 - re \cdot \left(re \cdot 0.5\right)\right)} \]
      4. Simplified70.4%

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

      if -1.2999999999999999e170 < im < -7.2e19

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub0100.0%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 3.9%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*3.9%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-13.9%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified3.9%

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

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

          \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) + -1 \cdot im} \]
        2. neg-mul-126.8%

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

          \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) - im} \]
        4. *-commutative26.8%

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

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

          \[\leadsto im \cdot \color{blue}{\left(0.5 \cdot {re}^{2}\right)} - im \]
        7. unpow226.8%

          \[\leadsto im \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) - im \]
      9. Simplified26.8%

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

      if -7.2e19 < im < 1.3999999999999999

      1. Initial program 10.7%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub010.7%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified10.7%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 96.2%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*96.2%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-196.2%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified96.2%

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

        \[\leadsto \color{blue}{-1 \cdot im} \]
      8. Step-by-step derivation
        1. neg-mul-155.0%

          \[\leadsto \color{blue}{-im} \]
      9. Simplified55.0%

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

      if 1.3999999999999999 < im < 1.60000000000000006e155

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub0100.0%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 47.8%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. +-commutative47.8%

          \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
        2. mul-1-neg47.8%

          \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
        3. unsub-neg47.8%

          \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
        4. associate-*r*47.8%

          \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
        5. distribute-rgt-out--47.8%

          \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
        6. *-commutative47.8%

          \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
      6. Simplified47.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
      7. Applied egg-rr4.9%

        \[\leadsto \cos re \cdot \left(\color{blue}{-1.1666666666666667} - im\right) \]
      8. Taylor expanded in re around 0 24.2%

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

          \[\leadsto \color{blue}{\left(-1 \cdot 1.1666666666666667 + -1 \cdot im\right)} + 0.5 \cdot \left({re}^{2} \cdot \left(1.1666666666666667 + im\right)\right) \]
        2. metadata-eval24.2%

          \[\leadsto \left(\color{blue}{-1.1666666666666667} + -1 \cdot im\right) + 0.5 \cdot \left({re}^{2} \cdot \left(1.1666666666666667 + im\right)\right) \]
        3. neg-mul-124.2%

          \[\leadsto \left(-1.1666666666666667 + \color{blue}{\left(-im\right)}\right) + 0.5 \cdot \left({re}^{2} \cdot \left(1.1666666666666667 + im\right)\right) \]
        4. sub-neg24.2%

          \[\leadsto \color{blue}{\left(-1.1666666666666667 - im\right)} + 0.5 \cdot \left({re}^{2} \cdot \left(1.1666666666666667 + im\right)\right) \]
        5. +-commutative24.2%

          \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot \left(1.1666666666666667 + im\right)\right) + \left(-1.1666666666666667 - im\right)} \]
        6. unpow224.2%

          \[\leadsto 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(1.1666666666666667 + im\right)\right) + \left(-1.1666666666666667 - im\right) \]
        7. associate-*r*24.2%

          \[\leadsto \color{blue}{\left(0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(1.1666666666666667 + im\right)} + \left(-1.1666666666666667 - im\right) \]
        8. *-commutative24.2%

          \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot 0.5\right)} \cdot \left(1.1666666666666667 + im\right) + \left(-1.1666666666666667 - im\right) \]
        9. associate-*r*24.2%

          \[\leadsto \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(1.1666666666666667 + im\right) + \left(-1.1666666666666667 - im\right) \]
        10. sub-neg24.2%

          \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(1.1666666666666667 + im\right) + \color{blue}{\left(-1.1666666666666667 + \left(-im\right)\right)} \]
        11. metadata-eval24.2%

          \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(1.1666666666666667 + im\right) + \left(\color{blue}{-1 \cdot 1.1666666666666667} + \left(-im\right)\right) \]
        12. neg-mul-124.2%

          \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(1.1666666666666667 + im\right) + \left(-1 \cdot 1.1666666666666667 + \color{blue}{-1 \cdot im}\right) \]
        13. distribute-lft-in24.2%

          \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(1.1666666666666667 + im\right) + \color{blue}{-1 \cdot \left(1.1666666666666667 + im\right)} \]
        14. distribute-rgt-out24.2%

          \[\leadsto \color{blue}{\left(1.1666666666666667 + im\right) \cdot \left(re \cdot \left(re \cdot 0.5\right) + -1\right)} \]
        15. +-commutative24.2%

          \[\leadsto \color{blue}{\left(im + 1.1666666666666667\right)} \cdot \left(re \cdot \left(re \cdot 0.5\right) + -1\right) \]
      10. Simplified24.2%

        \[\leadsto \color{blue}{\left(im + 1.1666666666666667\right) \cdot \left(re \cdot \left(re \cdot 0.5\right) + -1\right)} \]
    11. Recombined 4 regimes into one program.
    12. Final simplification50.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+170}:\\ \;\;\;\;\frac{im \cdot im}{im \cdot \left(-1 - re \cdot \left(0.5 \cdot re\right)\right)}\\ \mathbf{elif}\;im \leq -7.2 \cdot 10^{+19}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+155}:\\ \;\;\;\;\left(im + 1.1666666666666667\right) \cdot \left(-1 + re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{im \cdot im}{im \cdot \left(-1 - re \cdot \left(0.5 \cdot re\right)\right)}\\ \end{array} \]

    Alternative 8: 55.6% accurate, 14.6× speedup?

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

      1. Initial program 98.4%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub098.4%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 68.2%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. +-commutative68.2%

          \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
        2. mul-1-neg68.2%

          \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
        3. unsub-neg68.2%

          \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
        4. associate-*r*68.2%

          \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
        5. distribute-rgt-out--68.2%

          \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
        6. *-commutative68.2%

          \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
      6. Simplified68.2%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
      7. Taylor expanded in re around 0 8.9%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
      8. Step-by-step derivation
        1. associate--l+8.9%

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

          \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
        3. distribute-lft1-in62.9%

          \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
        4. *-commutative62.9%

          \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + 1\right)} \]
        5. *-inverses62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot {re}^{2} + \color{blue}{\frac{e^{\cos re}}{e^{\cos re}}}\right) \]
        6. +-commutative62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \color{blue}{\left(\frac{e^{\cos re}}{e^{\cos re}} + -0.5 \cdot {re}^{2}\right)} \]
        7. *-inverses62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(\color{blue}{1} + -0.5 \cdot {re}^{2}\right) \]
        8. unpow262.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + -0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        9. associate-*r*62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) \]
        10. *-commutative62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right) \]
        11. *-commutative62.9%

          \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \color{blue}{\left(re \cdot -0.5\right)}\right) \]
      9. Simplified62.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)} \]
      10. Step-by-step derivation
        1. sub-neg62.9%

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

          \[\leadsto \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
        3. unpow362.9%

          \[\leadsto \left(\color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} \cdot -0.16666666666666666 + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
        4. associate-*l*62.9%

          \[\leadsto \left(\color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)} + \left(-im\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
        5. fma-def62.9%

          \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      11. Applied egg-rr62.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, im \cdot -0.16666666666666666, -im\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      12. Step-by-step derivation
        1. fma-udef62.9%

          \[\leadsto \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) + \left(-im\right)\right)} \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right) \]
      13. Applied egg-rr62.9%

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

      if -2.1e15 < im < 1.69999999999999996e-24

      1. Initial program 8.8%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub08.8%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified8.8%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 98.1%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*98.1%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-198.1%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified98.1%

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

        \[\leadsto \color{blue}{-1 \cdot im} \]
      8. Step-by-step derivation
        1. neg-mul-156.1%

          \[\leadsto \color{blue}{-im} \]
      9. Simplified56.1%

        \[\leadsto \color{blue}{-im} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification59.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+15} \lor \neg \left(im \leq 1.7 \cdot 10^{-24}\right):\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

    Alternative 9: 32.1% accurate, 34.1× speedup?

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

      1. Initial program 55.1%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub055.1%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified55.1%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 51.2%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*51.2%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-151.2%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified51.2%

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

        \[\leadsto \color{blue}{-1 \cdot im} \]
      8. Step-by-step derivation
        1. neg-mul-135.3%

          \[\leadsto \color{blue}{-im} \]
      9. Simplified35.3%

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

      if 5.7000000000000002e110 < re

      1. Initial program 41.5%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub041.5%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified41.5%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in re around 0 1.1%

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

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

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

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

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

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

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

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

          \[\leadsto 0.5 \cdot \left(im \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      10. Simplified23.2%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 5.7 \cdot 10^{+110}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

    Alternative 10: 32.2% accurate, 34.1× speedup?

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

      1. Initial program 55.1%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub055.1%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified55.1%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 51.2%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*51.2%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-151.2%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified51.2%

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

        \[\leadsto \color{blue}{-1 \cdot im} \]
      8. Step-by-step derivation
        1. neg-mul-135.3%

          \[\leadsto \color{blue}{-im} \]
      9. Simplified35.3%

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

      if 5.7000000000000002e110 < re

      1. Initial program 41.5%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub041.5%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified41.5%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in re around 0 1.1%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right) \cdot 0.5} \]
        2. unpow223.2%

          \[\leadsto \left(im \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot 0.5 \]
        3. *-commutative23.2%

          \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot im\right)} \cdot 0.5 \]
        4. associate-*r*23.2%

          \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)} \]
        5. associate-*l*23.3%

          \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)} \]
      10. Simplified23.3%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 5.7 \cdot 10^{+110}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\\ \end{array} \]

    Alternative 11: 35.9% accurate, 34.3× speedup?

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

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub052.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified52.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 53.3%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*53.3%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
      2. neg-mul-153.3%

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified53.3%

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

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

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) + -1 \cdot im} \]
      2. neg-mul-136.3%

        \[\leadsto 0.5 \cdot \left(im \cdot {re}^{2}\right) + \color{blue}{\left(-im\right)} \]
      3. unsub-neg36.3%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) - im} \]
      4. *-commutative36.3%

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

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      6. *-commutative36.3%

        \[\leadsto im \cdot \color{blue}{\left(0.5 \cdot {re}^{2}\right)} - im \]
      7. unpow236.3%

        \[\leadsto im \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) - im \]
    9. Simplified36.3%

      \[\leadsto \color{blue}{im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im} \]
    10. Final simplification36.3%

      \[\leadsto im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im \]

    Alternative 12: 35.9% accurate, 34.3× speedup?

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

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub052.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified52.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 3.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -2 \cdot \left(im \cdot 0.5 + im \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)}\right) \]
      4. associate-*r*36.3%

        \[\leadsto -2 \cdot \left(im \cdot 0.5 + im \cdot \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right)}\right) \]
      5. distribute-lft-in36.3%

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

        \[\leadsto -2 \cdot \color{blue}{\left(0.5 \cdot im\right)} + -2 \cdot \left(im \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \]
      7. associate-*r*36.3%

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

        \[\leadsto \color{blue}{-1} \cdot im + -2 \cdot \left(im \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \]
      9. neg-mul-136.3%

        \[\leadsto \color{blue}{\left(-im\right)} + -2 \cdot \left(im \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \]
      10. associate-*r*36.3%

        \[\leadsto \left(-im\right) + \color{blue}{\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      11. *-commutative36.3%

        \[\leadsto \left(-im\right) + \color{blue}{\left(im \cdot -2\right)} \cdot \left(re \cdot \left(re \cdot -0.25\right)\right) \]
      12. associate-*r*36.3%

        \[\leadsto \left(-im\right) + \left(im \cdot -2\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \]
      13. *-commutative36.3%

        \[\leadsto \left(-im\right) + \left(im \cdot -2\right) \cdot \color{blue}{\left(-0.25 \cdot \left(re \cdot re\right)\right)} \]
      14. associate-*r*36.3%

        \[\leadsto \left(-im\right) + \color{blue}{\left(\left(im \cdot -2\right) \cdot -0.25\right) \cdot \left(re \cdot re\right)} \]
      15. associate-*l*36.3%

        \[\leadsto \left(-im\right) + \color{blue}{\left(im \cdot \left(-2 \cdot -0.25\right)\right)} \cdot \left(re \cdot re\right) \]
      16. metadata-eval36.3%

        \[\leadsto \left(-im\right) + \left(im \cdot \color{blue}{0.5}\right) \cdot \left(re \cdot re\right) \]
      17. *-commutative36.3%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot im\right)} \cdot \left(re \cdot re\right) \]
      18. associate-*r*36.3%

        \[\leadsto \left(-im\right) + \color{blue}{0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)} \]
      19. unpow236.3%

        \[\leadsto \left(-im\right) + 0.5 \cdot \left(im \cdot \color{blue}{{re}^{2}}\right) \]
      20. +-commutative36.3%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) + \left(-im\right)} \]
      21. unsub-neg36.3%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) - im} \]
    10. Simplified36.4%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
    11. Final simplification36.4%

      \[\leadsto re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im \]

    Alternative 13: 31.6% accurate, 61.0× speedup?

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

      1. Initial program 53.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub053.0%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified53.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in im around 0 53.1%

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      5. Step-by-step derivation
        1. associate-*r*53.1%

          \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
        2. neg-mul-153.1%

          \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
      6. Simplified53.1%

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

        \[\leadsto \color{blue}{-1 \cdot im} \]
      8. Step-by-step derivation
        1. neg-mul-133.8%

          \[\leadsto \color{blue}{-im} \]
      9. Simplified33.8%

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

      if 4.3999999999999999e171 < re

      1. Initial program 51.9%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Step-by-step derivation
        1. neg-sub051.9%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
      3. Simplified51.9%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      4. Taylor expanded in re around 0 0.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
      7. Applied egg-rr25.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, re, -re\right)} \]
      8. Step-by-step derivation
        1. fma-neg25.8%

          \[\leadsto \color{blue}{re \cdot re - re} \]
      9. Simplified25.8%

        \[\leadsto \color{blue}{re \cdot re - re} \]
      10. Taylor expanded in re around inf 25.8%

        \[\leadsto \color{blue}{{re}^{2}} \]
      11. Step-by-step derivation
        1. unpow225.8%

          \[\leadsto \color{blue}{re \cdot re} \]
      12. Simplified25.8%

        \[\leadsto \color{blue}{re \cdot re} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification32.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 4.4 \cdot 10^{+171}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot re\\ \end{array} \]

    Alternative 14: 29.5% accurate, 154.5× speedup?

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

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub052.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified52.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 53.3%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*53.3%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
      2. neg-mul-153.3%

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified53.3%

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

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-131.0%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified31.0%

      \[\leadsto \color{blue}{-im} \]
    10. Final simplification31.0%

      \[\leadsto -im \]

    Alternative 15: 3.0% accurate, 309.0× speedup?

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

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub052.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified52.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 3.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr2.9%

      \[\leadsto \color{blue}{\left|re\right|} \]
    8. Step-by-step derivation
      1. unpow12.9%

        \[\leadsto \left|\color{blue}{{re}^{1}}\right| \]
      2. *-inverses2.9%

        \[\leadsto \left|{re}^{\color{blue}{\left(\frac{e^{\cos re}}{e^{\cos re}}\right)}}\right| \]
      3. sqr-pow1.7%

        \[\leadsto \left|\color{blue}{{re}^{\left(\frac{\frac{e^{\cos re}}{e^{\cos re}}}{2}\right)} \cdot {re}^{\left(\frac{\frac{e^{\cos re}}{e^{\cos re}}}{2}\right)}}\right| \]
      4. fabs-sqr1.7%

        \[\leadsto \color{blue}{{re}^{\left(\frac{\frac{e^{\cos re}}{e^{\cos re}}}{2}\right)} \cdot {re}^{\left(\frac{\frac{e^{\cos re}}{e^{\cos re}}}{2}\right)}} \]
      5. sqr-pow3.1%

        \[\leadsto \color{blue}{{re}^{\left(\frac{e^{\cos re}}{e^{\cos re}}\right)}} \]
      6. *-inverses3.1%

        \[\leadsto {re}^{\color{blue}{1}} \]
      7. unpow13.1%

        \[\leadsto \color{blue}{re} \]
    9. Simplified3.1%

      \[\leadsto \color{blue}{re} \]
    10. Final simplification3.1%

      \[\leadsto re \]

    Developer target: 99.8% accurate, 0.8× speedup?

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

    Reproduce

    ?
    herbie shell --seed 2023275 
    (FPCore (re im)
      :name "math.sin on complex, imaginary part"
      :precision binary64
    
      :herbie-target
      (if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
    
      (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))