math.sin on complex, imaginary part

Percentage Accurate: 54.5% → 99.3%
Time: 10.0s
Alternatives: 14
Speedup: 2.8×

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 14 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.5% 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.3% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0 or 5.0000000000000002e-14 < (-.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. sub0-neg100.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 -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000002e-14

    1. Initial program 7.1%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.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 99.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({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 -\infty \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-14}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 2: 93.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.25 \cdot 10^{+173} \lor \neg \left(im \leq -0.05 \lor \neg \left(im \leq 0.122\right) \land im \leq 5.5 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 -1.25e+173)
         (not (or (<= im -0.05) (and (not (<= im 0.122)) (<= im 5.5e+102)))))
   (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
   (* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -1.25e+173) || !((im <= -0.05) || (!(im <= 0.122) && (im <= 5.5e+102)))) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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 <= (-1.25d+173)) .or. (.not. (im <= (-0.05d0)) .or. (.not. (im <= 0.122d0)) .and. (im <= 5.5d+102))) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - 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 <= -1.25e+173) || !((im <= -0.05) || (!(im <= 0.122) && (im <= 5.5e+102)))) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -1.25e+173) or not ((im <= -0.05) or (not (im <= 0.122) and (im <= 5.5e+102))):
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	else:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -1.25e+173) || !((im <= -0.05) || (!(im <= 0.122) && (im <= 5.5e+102))))
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - 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 <= -1.25e+173) || ~(((im <= -0.05) || (~((im <= 0.122)) && (im <= 5.5e+102)))))
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	else
		tmp = 0.5 * (exp(-im) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -1.25e+173], N[Not[Or[LessEqual[im, -0.05], And[N[Not[LessEqual[im, 0.122]], $MachinePrecision], LessEqual[im, 5.5e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $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 -1.25 \cdot 10^{+173} \lor \neg \left(im \leq -0.05 \lor \neg \left(im \leq 0.122\right) \land im \leq 5.5 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 < -1.25000000000000009e173 or -0.050000000000000003 < im < 0.122 or 5.49999999999999981e102 < im

    1. Initial program 37.6%

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

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

      \[\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}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.8%

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

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

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

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

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

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

    if -1.25000000000000009e173 < im < -0.050000000000000003 or 0.122 < im < 5.49999999999999981e102

    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. sub0-neg100.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 81.3%

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

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

Alternative 3: 95.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -5.7 \cdot 10^{+102}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -220:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

\mathbf{elif}\;im \leq 0.1 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.6999999999999999e102 or -220 < im < 0.10000000000000001 or 5.49999999999999981e102 < im

    1. Initial program 42.5%

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

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

      \[\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.4%

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

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

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

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

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

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

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

    if -5.6999999999999999e102 < im < -220

    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. sub0-neg100.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(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

    if 0.10000000000000001 < im < 5.49999999999999981e102

    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. sub0-neg100.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 84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.7 \cdot 10^{+102}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -220:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{elif}\;im \leq 0.1 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 4: 87.0% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.3 \cdot 10^{+210}:\\
\;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

\mathbf{elif}\;im \leq -0.023 \lor \neg \left(im \leq 9 \cdot 10^{-5}\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


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

    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. sub0-neg100.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}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 0.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+0.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*0.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-in92.9%

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

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

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

    if -3.29999999999999995e210 < im < -0.023 or 9.00000000000000057e-5 < im

    1. Initial program 99.8%

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

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

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

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

    if -0.023 < im < 9.00000000000000057e-5

    1. Initial program 6.5%

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

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

      \[\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(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.5%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative99.5%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.5%

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

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

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

Alternative 5: 77.5% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;im \leq -2.15 \cdot 10^{+96}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -6.4 \cdot 10^{+17} \lor \neg \left(im \leq 9 \cdot 10^{-5}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.99999999999999953e214 or -2.15000000000000001e96 < im < -6.4e17 or 9.00000000000000057e-5 < im

    1. Initial program 99.8%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.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 65.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 11.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+11.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*11.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-in63.0%

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

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

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

    if -4.99999999999999953e214 < im < -2.15000000000000001e96

    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. sub0-neg100.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 88.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 81.5%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -6.4e17 < im < 9.00000000000000057e-5

    1. Initial program 9.9%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified9.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 96.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.0%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5 \cdot 10^{+214}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -2.15 \cdot 10^{+96}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17} \lor \neg \left(im \leq 9 \cdot 10^{-5}\right):\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 6: 54.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{if}\;im \leq -2.4 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 7.6 \cdot 10^{+15}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1 (- (* (* re re) (* im 0.5)) im)))
   (if (<= im -2.4e+94)
     t_0
     (if (<= im -6.4e+17)
       t_1
       (if (<= im 7.6e+15) (- im) (if (<= im 1.7e+106) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = ((re * re) * (im * 0.5)) - im;
	double tmp;
	if (im <= -2.4e+94) {
		tmp = t_0;
	} else if (im <= -6.4e+17) {
		tmp = t_1;
	} else if (im <= 7.6e+15) {
		tmp = -im;
	} else if (im <= 1.7e+106) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = ((re * re) * (im * 0.5d0)) - im
    if (im <= (-2.4d+94)) then
        tmp = t_0
    else if (im <= (-6.4d+17)) then
        tmp = t_1
    else if (im <= 7.6d+15) then
        tmp = -im
    else if (im <= 1.7d+106) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = ((re * re) * (im * 0.5)) - im;
	double tmp;
	if (im <= -2.4e+94) {
		tmp = t_0;
	} else if (im <= -6.4e+17) {
		tmp = t_1;
	} else if (im <= 7.6e+15) {
		tmp = -im;
	} else if (im <= 1.7e+106) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = ((re * re) * (im * 0.5)) - im
	tmp = 0
	if im <= -2.4e+94:
		tmp = t_0
	elif im <= -6.4e+17:
		tmp = t_1
	elif im <= 7.6e+15:
		tmp = -im
	elif im <= 1.7e+106:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im)
	tmp = 0.0
	if (im <= -2.4e+94)
		tmp = t_0;
	elseif (im <= -6.4e+17)
		tmp = t_1;
	elseif (im <= 7.6e+15)
		tmp = Float64(-im);
	elseif (im <= 1.7e+106)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = ((re * re) * (im * 0.5)) - im;
	tmp = 0.0;
	if (im <= -2.4e+94)
		tmp = t_0;
	elseif (im <= -6.4e+17)
		tmp = t_1;
	elseif (im <= 7.6e+15)
		tmp = -im;
	elseif (im <= 1.7e+106)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -2.4e+94], t$95$0, If[LessEqual[im, -6.4e+17], t$95$1, If[LessEqual[im, 7.6e+15], (-im), If[LessEqual[im, 1.7e+106], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{if}\;im \leq -2.4 \cdot 10^{+94}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq 7.6 \cdot 10^{+15}:\\
\;\;\;\;-im\\

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+106}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.39999999999999983e94 or 1.69999999999999997e106 < 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. sub0-neg100.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 95.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 73.1%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -2.39999999999999983e94 < im < -6.4e17 or 7.6e15 < im < 1.69999999999999997e106

    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. sub0-neg100.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.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg3.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative3.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.7%

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

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

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

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

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

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

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

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

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

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

    if -6.4e17 < im < 7.6e15

    1. Initial program 13.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified13.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 93.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 46.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.4 \cdot 10^{+94}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 7.6 \cdot 10^{+15}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+106}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 7: 75.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -1.9 \cdot 10^{+96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -1.9e+96)
     t_0
     (if (<= im -6.4e+17)
       (- (* (* re re) (* im 0.5)) im)
       (if (<= im 4.7e-5) (* im (- (cos re))) (- t_0 im))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -1.9e+96) {
		tmp = t_0;
	} else if (im <= -6.4e+17) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 4.7e-5) {
		tmp = im * -cos(re);
	} else {
		tmp = t_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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-1.9d+96)) then
        tmp = t_0
    else if (im <= (-6.4d+17)) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (im <= 4.7d-5) then
        tmp = im * -cos(re)
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -1.9e+96) {
		tmp = t_0;
	} else if (im <= -6.4e+17) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 4.7e-5) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -1.9e+96:
		tmp = t_0
	elif im <= -6.4e+17:
		tmp = ((re * re) * (im * 0.5)) - im
	elif im <= 4.7e-5:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -1.9e+96)
		tmp = t_0;
	elseif (im <= -6.4e+17)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (im <= 4.7e-5)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -1.9e+96)
		tmp = t_0;
	elseif (im <= -6.4e+17)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (im <= 4.7e-5)
		tmp = im * -cos(re);
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -1.9e+96], t$95$0, If[LessEqual[im, -6.4e+17], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 4.7e-5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -1.9 \cdot 10^{+96}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 - im\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.9000000000000001e96

    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. sub0-neg100.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 91.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 71.5%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -1.9000000000000001e96 < im < -6.4e17

    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. sub0-neg100.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.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg3.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative3.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.6%

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

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

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

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

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

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

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

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

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

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

    if -6.4e17 < im < 4.69999999999999972e-5

    1. Initial program 9.9%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified9.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 96.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.0%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.0%

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

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

    if 4.69999999999999972e-5 < im

    1. Initial program 99.7%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.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 70.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.9 \cdot 10^{+96}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 8: 75.1% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+96}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.2 \cdot 10^{+61}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.1000000000000001e96 or 1.1999999999999999e61 < 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. sub0-neg100.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 87.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 66.1%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -2.1000000000000001e96 < im < -6.4e17

    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. sub0-neg100.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.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg3.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative3.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.6%

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

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

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

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

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

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

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

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

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

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

    if -6.4e17 < im < 1.1999999999999999e61

    1. Initial program 16.5%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg89.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative89.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in89.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+96}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+17}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 1.2 \cdot 10^{+61}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 9: 36.7% accurate, 12.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot re\right) \cdot 0.75\\ \mathbf{if}\;re \leq 4.2 \cdot 10^{+75}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;re \leq 1.75 \cdot 10^{+126}:\\ \;\;\;\;\frac{2.25 - t_0 \cdot t_0}{-1.5 - t_0}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* re re) 0.75)))
   (if (<= re 4.2e+75)
     (- (* (* re re) (* im 0.5)) im)
     (if (<= re 1.75e+126)
       (/ (- 2.25 (* t_0 t_0)) (- -1.5 t_0))
       (- (* re (* re (* im 0.5))) im)))))
double code(double re, double im) {
	double t_0 = (re * re) * 0.75;
	double tmp;
	if (re <= 4.2e+75) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (re <= 1.75e+126) {
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	} else {
		tmp = (re * (re * (im * 0.5))) - 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 = (re * re) * 0.75d0
    if (re <= 4.2d+75) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (re <= 1.75d+126) then
        tmp = (2.25d0 - (t_0 * t_0)) / ((-1.5d0) - t_0)
    else
        tmp = (re * (re * (im * 0.5d0))) - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re * re) * 0.75;
	double tmp;
	if (re <= 4.2e+75) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (re <= 1.75e+126) {
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	} else {
		tmp = (re * (re * (im * 0.5))) - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = (re * re) * 0.75
	tmp = 0
	if re <= 4.2e+75:
		tmp = ((re * re) * (im * 0.5)) - im
	elif re <= 1.75e+126:
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0)
	else:
		tmp = (re * (re * (im * 0.5))) - im
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re * re) * 0.75)
	tmp = 0.0
	if (re <= 4.2e+75)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (re <= 1.75e+126)
		tmp = Float64(Float64(2.25 - Float64(t_0 * t_0)) / Float64(-1.5 - t_0));
	else
		tmp = Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re * re) * 0.75;
	tmp = 0.0;
	if (re <= 4.2e+75)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (re <= 1.75e+126)
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	else
		tmp = (re * (re * (im * 0.5))) - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]}, If[LessEqual[re, 4.2e+75], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 1.75e+126], N[(N[(2.25 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot 0.75\\
\mathbf{if}\;re \leq 4.2 \cdot 10^{+75}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\

\mathbf{elif}\;re \leq 1.75 \cdot 10^{+126}:\\
\;\;\;\;\frac{2.25 - t_0 \cdot t_0}{-1.5 - t_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < 4.19999999999999997e75

    1. Initial program 51.5%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg54.4%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative54.4%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in54.4%

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

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

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

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

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

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

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

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

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

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

    if 4.19999999999999997e75 < re < 1.7500000000000001e126

    1. Initial program 64.2%

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

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

      \[\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.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot 0.5\right) \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
      3. metadata-eval38.3%

        \[\leadsto \frac{\color{blue}{-1.5} \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      4. metadata-eval38.3%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{-1.5} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      5. metadata-eval38.3%

        \[\leadsto \frac{\color{blue}{2.25} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      6. *-commutative38.3%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)} \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      7. *-commutative38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right) \cdot \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      8. associate-*r*38.3%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      9. associate-*l*38.3%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)} \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      10. metadata-eval38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      11. associate-*r*38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      12. associate-*l*38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      13. metadata-eval38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      14. metadata-eval38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{\color{blue}{-1.5} - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      15. *-commutative38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3}} \]
      16. associate-*r*38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3} \]
      17. associate-*l*38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)}} \]
      18. metadata-eval38.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot \color{blue}{0.75}} \]
    9. Applied egg-rr38.3%

      \[\leadsto \color{blue}{\frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot 0.75}} \]

    if 1.7500000000000001e126 < re

    1. Initial program 50.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified50.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 54.8%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg54.8%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative54.8%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in54.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg21.6%

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)} + \left(-im\right) \]
    11. Applied egg-rr21.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 4.2 \cdot 10^{+75}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;re \leq 1.75 \cdot 10^{+126}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot 0.75}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \end{array} \]

Alternative 10: 36.6% accurate, 34.3× speedup?

\[\begin{array}{l} \\ \left(re \cdot re\right) \cdot \left(im \cdot 0.5\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(Float64(re * 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[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]
\begin{array}{l}

\\
\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im
\end{array}
Derivation
  1. Initial program 51.7%

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified51.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 54.0%

    \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
  5. Step-by-step derivation
    1. mul-1-neg54.0%

      \[\leadsto \color{blue}{-\cos re \cdot im} \]
    2. *-commutative54.0%

      \[\leadsto -\color{blue}{im \cdot \cos re} \]
    3. distribute-lft-neg-in54.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 36.6% 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 51.7%

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified51.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 54.0%

    \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
  5. Step-by-step derivation
    1. mul-1-neg54.0%

      \[\leadsto \color{blue}{-\cos re \cdot im} \]
    2. *-commutative54.0%

      \[\leadsto -\color{blue}{im \cdot \cos re} \]
    3. distribute-lft-neg-in54.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)} + \left(-im\right) \]
  11. Applied egg-rr34.3%

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

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

Alternative 12: 31.2% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.65 \cdot 10^{+182}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.65e+182) (- im) (* (* re re) 0.75)))
double code(double re, double im) {
	double tmp;
	if (re <= 1.65e+182) {
		tmp = -im;
	} else {
		tmp = (re * re) * 0.75;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.65d+182) then
        tmp = -im
    else
        tmp = (re * re) * 0.75d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.65e+182) {
		tmp = -im;
	} else {
		tmp = (re * re) * 0.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.65e+182:
		tmp = -im
	else:
		tmp = (re * re) * 0.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.65e+182)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(re * re) * 0.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.65e+182)
		tmp = -im;
	else
		tmp = (re * re) * 0.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.65e+182], (-im), N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.65 \cdot 10^{+182}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.65e182

    1. Initial program 51.4%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified51.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 85.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 29.8%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified29.8%

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

    if 1.65e182 < re

    1. Initial program 54.8%

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

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

      \[\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(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot 0.5\right) \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
      3. metadata-eval0.0%

        \[\leadsto \frac{\color{blue}{-1.5} \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      4. metadata-eval0.0%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{-1.5} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      5. metadata-eval0.0%

        \[\leadsto \frac{\color{blue}{2.25} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      6. *-commutative0.0%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)} \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      7. *-commutative0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right) \cdot \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      8. associate-*r*0.0%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      9. associate-*l*0.0%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)} \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      10. metadata-eval0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      11. associate-*r*0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      12. associate-*l*0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      13. metadata-eval0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      14. metadata-eval0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{\color{blue}{-1.5} - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      15. *-commutative0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3}} \]
      16. associate-*r*0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3} \]
      17. associate-*l*0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)}} \]
      18. metadata-eval0.0%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot \color{blue}{0.75}} \]
    9. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot 0.75}} \]
    10. Taylor expanded in re around inf 30.6%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    11. Step-by-step derivation
      1. unpow230.6%

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    12. Simplified30.6%

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

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

Alternative 13: 29.4% 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 51.7%

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified51.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 84.4%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  8. Taylor expanded in im around 0 27.3%

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

      \[\leadsto \color{blue}{-im} \]
  10. Simplified27.3%

    \[\leadsto \color{blue}{-im} \]
  11. Final simplification27.3%

    \[\leadsto -im \]

Alternative 14: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ -1.5 \end{array} \]
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
	return -1.5;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -1.5d0
end function
public static double code(double re, double im) {
	return -1.5;
}
def code(re, im):
	return -1.5
function code(re, im)
	return -1.5
end
function tmp = code(re, im)
	tmp = -1.5;
end
code[re_, im_] := -1.5
\begin{array}{l}

\\
-1.5
\end{array}
Derivation
  1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1.5} \]
  9. Final simplification2.9%

    \[\leadsto -1.5 \]

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 2023201 
(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))))