math.cos on complex, imaginary part

Percentage Accurate: 64.5% → 99.8%
Time: 8.9s
Alternatives: 18
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 18 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: 64.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.20000000000000001 or 9.9999999999999995e-8 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]

    if -0.20000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.9999999999999995e-8

    1. Initial program 30.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.2 \lor \neg \left(t_0 \leq 10^{-7}\right):\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin 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 -0.2) (not (<= t_0 1e-7)))
     (* t_0 (* 0.5 (sin re)))
     (* (sin 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 <= -0.2) || !(t_0 <= 1e-7)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-0.2d0)) .or. (.not. (t_0 <= 1d-7))) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -0.2) || !(t_0 <= 1e-7)) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(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 <= -0.2) or not (t_0 <= 1e-7):
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(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 <= -0.2) || !(t_0 <= 1e-7))
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(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 <= -0.2) || ~((t_0 <= 1e-7)))
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(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, -0.2], N[Not[LessEqual[t$95$0, 1e-7]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[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 -0.2 \lor \neg \left(t_0 \leq 10^{-7}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\

\mathbf{else}:\\
\;\;\;\;\sin 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 (neg.f64 im)) (exp.f64 im)) < -0.20000000000000001 or 9.9999999999999995e-8 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]

    if -0.20000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.9999999999999995e-8

    1. Initial program 30.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

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

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

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

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

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

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

Alternative 3: 95.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ t_1 := {im}^{3} \cdot -0.16666666666666666\\ t_2 := \sin re \cdot t_1\\ \mathbf{if}\;im \leq -2.35 \cdot 10^{+103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -0.024:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.043:\\ \;\;\;\;\sin re \cdot \left(t_1 - im\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im)) (exp im)) (* 0.5 re)))
        (t_1 (* (pow im 3.0) -0.16666666666666666))
        (t_2 (* (sin re) t_1)))
   (if (<= im -2.35e+103)
     t_2
     (if (<= im -0.024)
       t_0
       (if (<= im 0.043)
         (* (sin re) (- t_1 im))
         (if (<= im 2e+102) t_0 t_2))))))
double code(double re, double im) {
	double t_0 = (exp(-im) - exp(im)) * (0.5 * re);
	double t_1 = pow(im, 3.0) * -0.16666666666666666;
	double t_2 = sin(re) * t_1;
	double tmp;
	if (im <= -2.35e+103) {
		tmp = t_2;
	} else if (im <= -0.024) {
		tmp = t_0;
	} else if (im <= 0.043) {
		tmp = sin(re) * (t_1 - im);
	} else if (im <= 2e+102) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = (exp(-im) - exp(im)) * (0.5d0 * re)
    t_1 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_2 = sin(re) * t_1
    if (im <= (-2.35d+103)) then
        tmp = t_2
    else if (im <= (-0.024d0)) then
        tmp = t_0
    else if (im <= 0.043d0) then
        tmp = sin(re) * (t_1 - im)
    else if (im <= 2d+102) then
        tmp = t_0
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
	double t_1 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_2 = Math.sin(re) * t_1;
	double tmp;
	if (im <= -2.35e+103) {
		tmp = t_2;
	} else if (im <= -0.024) {
		tmp = t_0;
	} else if (im <= 0.043) {
		tmp = Math.sin(re) * (t_1 - im);
	} else if (im <= 2e+102) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.exp(-im) - math.exp(im)) * (0.5 * re)
	t_1 = math.pow(im, 3.0) * -0.16666666666666666
	t_2 = math.sin(re) * t_1
	tmp = 0
	if im <= -2.35e+103:
		tmp = t_2
	elif im <= -0.024:
		tmp = t_0
	elif im <= 0.043:
		tmp = math.sin(re) * (t_1 - im)
	elif im <= 2e+102:
		tmp = t_0
	else:
		tmp = t_2
	return tmp
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re))
	t_1 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_2 = Float64(sin(re) * t_1)
	tmp = 0.0
	if (im <= -2.35e+103)
		tmp = t_2;
	elseif (im <= -0.024)
		tmp = t_0;
	elseif (im <= 0.043)
		tmp = Float64(sin(re) * Float64(t_1 - im));
	elseif (im <= 2e+102)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (exp(-im) - exp(im)) * (0.5 * re);
	t_1 = (im ^ 3.0) * -0.16666666666666666;
	t_2 = sin(re) * t_1;
	tmp = 0.0;
	if (im <= -2.35e+103)
		tmp = t_2;
	elseif (im <= -0.024)
		tmp = t_0;
	elseif (im <= 0.043)
		tmp = sin(re) * (t_1 - im);
	elseif (im <= 2e+102)
		tmp = t_0;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[re], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[im, -2.35e+103], t$95$2, If[LessEqual[im, -0.024], t$95$0, If[LessEqual[im, 0.043], N[(N[Sin[re], $MachinePrecision] * N[(t$95$1 - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2e+102], t$95$0, t$95$2]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 0.043:\\
\;\;\;\;\sin re \cdot \left(t_1 - im\right)\\

\mathbf{elif}\;im \leq 2 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.35000000000000016e103 or 1.99999999999999995e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

    if -2.35000000000000016e103 < im < -0.024 or 0.042999999999999997 < im < 1.99999999999999995e102

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 79.9%

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

    if -0.024 < im < 0.042999999999999997

    1. Initial program 30.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+103}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -0.024:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 0.043:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 4: 85.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -5.6 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -850000000000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\ \mathbf{elif}\;im \leq 2.4:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (sin re) (* (pow im 3.0) -0.16666666666666666))))
   (if (<= im -5.6e+102)
     t_0
     (if (<= im -850000000000.0)
       (log1p (expm1 (* re 13.5)))
       (if (<= im 2.4) (* im (- (sin re))) t_0)))))
double code(double re, double im) {
	double t_0 = sin(re) * (pow(im, 3.0) * -0.16666666666666666);
	double tmp;
	if (im <= -5.6e+102) {
		tmp = t_0;
	} else if (im <= -850000000000.0) {
		tmp = log1p(expm1((re * 13.5)));
	} else if (im <= 2.4) {
		tmp = im * -sin(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.sin(re) * (Math.pow(im, 3.0) * -0.16666666666666666);
	double tmp;
	if (im <= -5.6e+102) {
		tmp = t_0;
	} else if (im <= -850000000000.0) {
		tmp = Math.log1p(Math.expm1((re * 13.5)));
	} else if (im <= 2.4) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.sin(re) * (math.pow(im, 3.0) * -0.16666666666666666)
	tmp = 0
	if im <= -5.6e+102:
		tmp = t_0
	elif im <= -850000000000.0:
		tmp = math.log1p(math.expm1((re * 13.5)))
	elif im <= 2.4:
		tmp = im * -math.sin(re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(sin(re) * Float64((im ^ 3.0) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -5.6e+102)
		tmp = t_0;
	elseif (im <= -850000000000.0)
		tmp = log1p(expm1(Float64(re * 13.5)));
	elseif (im <= 2.4)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6e+102], t$95$0, If[LessEqual[im, -850000000000.0], N[Log[1 + N[(Exp[N[(re * 13.5), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 2.4], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -850000000000:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.60000000000000037e102 or 2.39999999999999991 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 88.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    5. Taylor expanded in im around inf 88.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)} \]
    6. Step-by-step derivation
      1. *-commutative88.6%

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

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

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

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

    if -5.60000000000000037e102 < im < -8.5e11

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 73.9%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{27} \]
    4. Step-by-step derivation
      1. log1p-expm1-u35.5%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(0.5 \cdot re\right) \cdot 27\right)\right)} \]
      2. *-commutative35.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot 27\right)\right) \]
      3. associate-*l*35.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{re \cdot \left(0.5 \cdot 27\right)}\right)\right) \]
      4. metadata-eval35.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \color{blue}{13.5}\right)\right) \]
    5. Applied egg-rr35.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)} \]

    if -8.5e11 < im < 2.39999999999999991

    1. Initial program 32.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 97.1%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg97.1%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative97.1%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in97.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+102}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -850000000000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\ \mathbf{elif}\;im \leq 2.4:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 5: 76.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -7.8 \cdot 10^{+105}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\ \mathbf{elif}\;im \leq -950000000000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -6e+135)
   (* (pow im 3.0) (* re -0.16666666666666666))
   (if (<= im -7.8e+105)
     (log1p (expm1 (* re -1.5)))
     (if (<= im -950000000000.0)
       (log1p (expm1 (* re 13.5)))
       (if (<= im 4.2e-5)
         (* im (- (sin re)))
         (- (* re (* (pow im 3.0) -0.16666666666666666)) (* im re)))))))
double code(double re, double im) {
	double tmp;
	if (im <= -6e+135) {
		tmp = pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= -7.8e+105) {
		tmp = log1p(expm1((re * -1.5)));
	} else if (im <= -950000000000.0) {
		tmp = log1p(expm1((re * 13.5)));
	} else if (im <= 4.2e-5) {
		tmp = im * -sin(re);
	} else {
		tmp = (re * (pow(im, 3.0) * -0.16666666666666666)) - (im * re);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= -6e+135) {
		tmp = Math.pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= -7.8e+105) {
		tmp = Math.log1p(Math.expm1((re * -1.5)));
	} else if (im <= -950000000000.0) {
		tmp = Math.log1p(Math.expm1((re * 13.5)));
	} else if (im <= 4.2e-5) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = (re * (Math.pow(im, 3.0) * -0.16666666666666666)) - (im * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -6e+135:
		tmp = math.pow(im, 3.0) * (re * -0.16666666666666666)
	elif im <= -7.8e+105:
		tmp = math.log1p(math.expm1((re * -1.5)))
	elif im <= -950000000000.0:
		tmp = math.log1p(math.expm1((re * 13.5)))
	elif im <= 4.2e-5:
		tmp = im * -math.sin(re)
	else:
		tmp = (re * (math.pow(im, 3.0) * -0.16666666666666666)) - (im * re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -6e+135)
		tmp = Float64((im ^ 3.0) * Float64(re * -0.16666666666666666));
	elseif (im <= -7.8e+105)
		tmp = log1p(expm1(Float64(re * -1.5)));
	elseif (im <= -950000000000.0)
		tmp = log1p(expm1(Float64(re * 13.5)));
	elseif (im <= 4.2e-5)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = Float64(Float64(re * Float64((im ^ 3.0) * -0.16666666666666666)) - Float64(im * re));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, -6e+135], N[(N[Power[im, 3.0], $MachinePrecision] * N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -7.8e+105], N[Log[1 + N[(Exp[N[(re * -1.5), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, -950000000000.0], N[Log[1 + N[(Exp[N[(re * 13.5), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 4.2e-5], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(N[(re * N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im * re), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -7.8 \cdot 10^{+105}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\

\mathbf{elif}\;im \leq -950000000000:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -6.0000000000000001e135

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 80.6%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 80.6%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -7.79999999999999957e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 27.3%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{-3} \]
    4. Step-by-step derivation
      1. log1p-expm1-u72.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(0.5 \cdot re\right) \cdot -3\right)\right)} \]
      2. *-commutative72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot -3\right)\right) \]
      3. associate-*l*72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{re \cdot \left(0.5 \cdot -3\right)}\right)\right) \]
      4. metadata-eval72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \color{blue}{-1.5}\right)\right) \]
    5. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)} \]

    if -7.79999999999999957e105 < im < -9.5e11

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 75.0%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{27} \]
    4. Step-by-step derivation
      1. log1p-expm1-u34.1%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(0.5 \cdot re\right) \cdot 27\right)\right)} \]
      2. *-commutative34.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot 27\right)\right) \]
      3. associate-*l*34.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{re \cdot \left(0.5 \cdot 27\right)}\right)\right) \]
      4. metadata-eval34.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \color{blue}{13.5}\right)\right) \]
    5. Applied egg-rr34.1%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)} \]

    if -9.5e11 < im < 4.19999999999999977e-5

    1. Initial program 32.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 97.8%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in97.8%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified97.8%

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

    if 4.19999999999999977e-5 < im

    1. Initial program 99.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 71.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -7.8 \cdot 10^{+105}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\ \mathbf{elif}\;im \leq -950000000000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\ \end{array} \]

Alternative 6: 84.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im)))
double code(double re, double im) {
	return sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end function
public static double code(double re, double im) {
	return Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
def code(re, im):
	return math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
function code(re, im)
	return Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
end
function tmp = code(re, im)
	tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)
\end{array}
Derivation
  1. Initial program 65.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 85.6%

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

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

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

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

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

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

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

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

Alternative 7: 76.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\ \mathbf{elif}\;im \leq -0.098 \lor \neg \left(im \leq 4.7 \cdot 10^{-5}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -6e+135)
   (* (pow im 3.0) (* re -0.16666666666666666))
   (if (<= im -8.1e+105)
     (log1p (expm1 (* re -1.5)))
     (if (or (<= im -0.098) (not (<= im 4.7e-5)))
       (- (* re (* (pow im 3.0) -0.16666666666666666)) (* im re))
       (* im (- (sin re)))))))
double code(double re, double im) {
	double tmp;
	if (im <= -6e+135) {
		tmp = pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= -8.1e+105) {
		tmp = log1p(expm1((re * -1.5)));
	} else if ((im <= -0.098) || !(im <= 4.7e-5)) {
		tmp = (re * (pow(im, 3.0) * -0.16666666666666666)) - (im * re);
	} else {
		tmp = im * -sin(re);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= -6e+135) {
		tmp = Math.pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= -8.1e+105) {
		tmp = Math.log1p(Math.expm1((re * -1.5)));
	} else if ((im <= -0.098) || !(im <= 4.7e-5)) {
		tmp = (re * (Math.pow(im, 3.0) * -0.16666666666666666)) - (im * re);
	} else {
		tmp = im * -Math.sin(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -6e+135:
		tmp = math.pow(im, 3.0) * (re * -0.16666666666666666)
	elif im <= -8.1e+105:
		tmp = math.log1p(math.expm1((re * -1.5)))
	elif (im <= -0.098) or not (im <= 4.7e-5):
		tmp = (re * (math.pow(im, 3.0) * -0.16666666666666666)) - (im * re)
	else:
		tmp = im * -math.sin(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -6e+135)
		tmp = Float64((im ^ 3.0) * Float64(re * -0.16666666666666666));
	elseif (im <= -8.1e+105)
		tmp = log1p(expm1(Float64(re * -1.5)));
	elseif ((im <= -0.098) || !(im <= 4.7e-5))
		tmp = Float64(Float64(re * Float64((im ^ 3.0) * -0.16666666666666666)) - Float64(im * re));
	else
		tmp = Float64(im * Float64(-sin(re)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, -6e+135], N[(N[Power[im, 3.0], $MachinePrecision] * N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -8.1e+105], N[Log[1 + N[(Exp[N[(re * -1.5), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[im, -0.098], N[Not[LessEqual[im, 4.7e-5]], $MachinePrecision]], N[(N[(re * N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im * re), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\

\mathbf{elif}\;im \leq -0.098 \lor \neg \left(im \leq 4.7 \cdot 10^{-5}\right):\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 80.6%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 80.6%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -8.09999999999999998e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 27.3%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{-3} \]
    4. Step-by-step derivation
      1. log1p-expm1-u72.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(0.5 \cdot re\right) \cdot -3\right)\right)} \]
      2. *-commutative72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot -3\right)\right) \]
      3. associate-*l*72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{re \cdot \left(0.5 \cdot -3\right)}\right)\right) \]
      4. metadata-eval72.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \color{blue}{-1.5}\right)\right) \]
    5. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)} \]

    if -8.09999999999999998e105 < im < -0.098000000000000004 or 4.69999999999999972e-5 < im

    1. Initial program 99.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 73.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - re \cdot im \]
    5. Applied egg-rr47.5%

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

    if -0.098000000000000004 < im < 4.69999999999999972e-5

    1. Initial program 30.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in99.8%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -1.5\right)\right)\\ \mathbf{elif}\;im \leq -0.098 \lor \neg \left(im \leq 4.7 \cdot 10^{-5}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 8: 76.3% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

\mathbf{elif}\;im \leq -0.0088 \lor \neg \left(im \leq 4.7 \cdot 10^{-5}\right):\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 80.6%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 80.6%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -8.09999999999999998e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg4.2%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative4.2%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified4.2%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 37.1%

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

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

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

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

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

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

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

    if -8.09999999999999998e105 < im < -0.00880000000000000053 or 4.69999999999999972e-5 < im

    1. Initial program 99.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 73.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - re \cdot im \]
    5. Applied egg-rr47.5%

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

    if -0.00880000000000000053 < im < 4.69999999999999972e-5

    1. Initial program 30.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in99.8%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq -0.0088 \lor \neg \left(im \leq 4.7 \cdot 10^{-5}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666\right) - im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 9: 76.3% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

\mathbf{elif}\;im \leq -0.0016 \lor \neg \left(im \leq 2.3 \cdot 10^{-5}\right):\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 80.6%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 80.6%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -8.09999999999999998e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg4.2%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative4.2%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified4.2%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 37.1%

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

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

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

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

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

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

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

    if -8.09999999999999998e105 < im < -0.00160000000000000008 or 2.3e-5 < im

    1. Initial program 99.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 58.4%

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

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

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

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

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

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

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

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

    if -0.00160000000000000008 < im < 2.3e-5

    1. Initial program 30.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 99.8%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in99.8%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq -0.0016 \lor \neg \left(im \leq 2.3 \cdot 10^{-5}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 10: 76.3% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\
\;\;\;\;{re}^{3} \cdot \left(im \cdot 0.16666666666666666\right)\\

\mathbf{elif}\;im \leq -4.2 \cdot 10^{+20} \lor \neg \left(im \leq 700\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.0000000000000001e135 or -8.09999999999999998e105 < im < -4.2e20 or 700 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 75.7%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 58.3%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -8.09999999999999998e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg4.2%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative4.2%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified4.2%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 37.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)} \]
    8. Taylor expanded in re around inf 64.2%

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

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

        \[\leadsto \color{blue}{{re}^{3} \cdot \left(im \cdot 0.16666666666666666\right)} \]
    10. Simplified64.2%

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

    if -4.2e20 < im < 700

    1. Initial program 34.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 95.0%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in95.0%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified95.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;{re}^{3} \cdot \left(im \cdot 0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -4.2 \cdot 10^{+20} \lor \neg \left(im \leq 700\right):\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 11: 76.3% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

\mathbf{elif}\;im \leq -4.2 \cdot 10^{+20} \lor \neg \left(im \leq 480\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.0000000000000001e135 or -8.09999999999999998e105 < im < -4.2e20 or 480 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 75.7%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 58.3%

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

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

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

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

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

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

    if -6.0000000000000001e135 < im < -8.09999999999999998e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg4.2%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative4.2%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified4.2%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 37.1%

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

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

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

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

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

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

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

    if -4.2e20 < im < 480

    1. Initial program 34.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 95.0%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in95.0%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified95.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+135}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -8.1 \cdot 10^{+105}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq -4.2 \cdot 10^{+20} \lor \neg \left(im \leq 480\right):\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 12: 77.6% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.2 \cdot 10^{+20} \lor \neg \left(im \leq 820\right):\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -3.2e+20) (not (<= im 820.0)))
   (* (pow im 3.0) (* re -0.16666666666666666))
   (* im (- (sin re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -3.2e+20) || !(im <= 820.0)) {
		tmp = pow(im, 3.0) * (re * -0.16666666666666666);
	} else {
		tmp = im * -sin(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.2d+20)) .or. (.not. (im <= 820.0d0))) then
        tmp = (im ** 3.0d0) * (re * (-0.16666666666666666d0))
    else
        tmp = im * -sin(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -3.2e+20) || !(im <= 820.0)) {
		tmp = Math.pow(im, 3.0) * (re * -0.16666666666666666);
	} else {
		tmp = im * -Math.sin(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -3.2e+20) or not (im <= 820.0):
		tmp = math.pow(im, 3.0) * (re * -0.16666666666666666)
	else:
		tmp = im * -math.sin(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -3.2e+20) || !(im <= 820.0))
		tmp = Float64((im ^ 3.0) * Float64(re * -0.16666666666666666));
	else
		tmp = Float64(im * Float64(-sin(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -3.2e+20) || ~((im <= 820.0)))
		tmp = (im ^ 3.0) * (re * -0.16666666666666666);
	else
		tmp = im * -sin(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -3.2e+20], N[Not[LessEqual[im, 820.0]], $MachinePrecision]], N[(N[Power[im, 3.0], $MachinePrecision] * N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.2 \cdot 10^{+20} \lor \neg \left(im \leq 820\right):\\
\;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.2e20 or 820 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 71.3%

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

      \[\leadsto \color{blue}{-1 \cdot \left(re \cdot im\right) + -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    4. Taylor expanded in im around inf 55.5%

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

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

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

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

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

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

    if -3.2e20 < im < 820

    1. Initial program 34.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 95.0%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in95.0%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified95.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.2 \cdot 10^{+20} \lor \neg \left(im \leq 820\right):\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 13: 58.0% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.3 \cdot 10^{+21} \lor \neg \left(im \leq 1.05 \cdot 10^{+129}\right):\\
\;\;\;\;-im \cdot re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.3e21 or 1.04999999999999998e129 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.4%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.4%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified4.4%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 17.4%

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

        \[\leadsto \color{blue}{-re \cdot im} \]
      2. distribute-rgt-neg-in17.4%

        \[\leadsto \color{blue}{re \cdot \left(-im\right)} \]
    7. Simplified17.4%

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

    if -2.3e21 < im < 1.04999999999999998e129

    1. Initial program 44.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 81.5%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in81.5%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified81.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.3 \cdot 10^{+21} \lor \neg \left(im \leq 1.05 \cdot 10^{+129}\right):\\ \;\;\;\;-im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 14: 57.2% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.05 \cdot 10^{+33}:\\ \;\;\;\;\sqrt{re \cdot \left(re \cdot 182.25\right)}\\ \mathbf{elif}\;im \leq 1.06 \cdot 10^{+130}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-im \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -2.05e+33)
   (sqrt (* re (* re 182.25)))
   (if (<= im 1.06e+130) (* im (- (sin re))) (- (* im re)))))
double code(double re, double im) {
	double tmp;
	if (im <= -2.05e+33) {
		tmp = sqrt((re * (re * 182.25)));
	} else if (im <= 1.06e+130) {
		tmp = im * -sin(re);
	} else {
		tmp = -(im * re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-2.05d+33)) then
        tmp = sqrt((re * (re * 182.25d0)))
    else if (im <= 1.06d+130) then
        tmp = im * -sin(re)
    else
        tmp = -(im * re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -2.05e+33) {
		tmp = Math.sqrt((re * (re * 182.25)));
	} else if (im <= 1.06e+130) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = -(im * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -2.05e+33:
		tmp = math.sqrt((re * (re * 182.25)))
	elif im <= 1.06e+130:
		tmp = im * -math.sin(re)
	else:
		tmp = -(im * re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -2.05e+33)
		tmp = sqrt(Float64(re * Float64(re * 182.25)));
	elseif (im <= 1.06e+130)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = Float64(-Float64(im * re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -2.05e+33)
		tmp = sqrt((re * (re * 182.25)));
	elseif (im <= 1.06e+130)
		tmp = im * -sin(re);
	else
		tmp = -(im * re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -2.05e+33], N[Sqrt[N[(re * N[(re * 182.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.06e+130], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], (-N[(im * re), $MachinePrecision])]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.05 \cdot 10^{+33}:\\
\;\;\;\;\sqrt{re \cdot \left(re \cdot 182.25\right)}\\

\mathbf{elif}\;im \leq 1.06 \cdot 10^{+130}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\

\mathbf{else}:\\
\;\;\;\;-im \cdot re\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 69.5%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{27} \]
    4. Step-by-step derivation
      1. log1p-expm1-u23.1%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(0.5 \cdot re\right) \cdot 27\right)\right)} \]
      2. *-commutative23.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot 27\right)\right) \]
      3. associate-*l*23.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{re \cdot \left(0.5 \cdot 27\right)}\right)\right) \]
      4. metadata-eval23.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \color{blue}{13.5}\right)\right) \]
    5. Applied egg-rr23.1%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot 13.5\right)\right)} \]
    6. Step-by-step derivation
      1. log1p-expm1-u2.3%

        \[\leadsto \color{blue}{re \cdot 13.5} \]
      2. add-sqr-sqrt1.5%

        \[\leadsto \color{blue}{\sqrt{re \cdot 13.5} \cdot \sqrt{re \cdot 13.5}} \]
      3. sqrt-unprod13.3%

        \[\leadsto \color{blue}{\sqrt{\left(re \cdot 13.5\right) \cdot \left(re \cdot 13.5\right)}} \]
      4. *-commutative13.3%

        \[\leadsto \sqrt{\color{blue}{\left(13.5 \cdot re\right)} \cdot \left(re \cdot 13.5\right)} \]
      5. *-commutative13.3%

        \[\leadsto \sqrt{\left(13.5 \cdot re\right) \cdot \color{blue}{\left(13.5 \cdot re\right)}} \]
      6. swap-sqr13.3%

        \[\leadsto \sqrt{\color{blue}{\left(13.5 \cdot 13.5\right) \cdot \left(re \cdot re\right)}} \]
      7. metadata-eval13.3%

        \[\leadsto \sqrt{\color{blue}{182.25} \cdot \left(re \cdot re\right)} \]
    7. Applied egg-rr13.3%

      \[\leadsto \color{blue}{\sqrt{182.25 \cdot \left(re \cdot re\right)}} \]
    8. Step-by-step derivation
      1. associate-*r*13.3%

        \[\leadsto \sqrt{\color{blue}{\left(182.25 \cdot re\right) \cdot re}} \]
    9. Simplified13.3%

      \[\leadsto \color{blue}{\sqrt{\left(182.25 \cdot re\right) \cdot re}} \]

    if -2.04999999999999997e33 < im < 1.06e130

    1. Initial program 45.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 79.5%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in79.5%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified79.5%

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

    if 1.06e130 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 5.3%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg5.3%

        \[\leadsto \color{blue}{-\sin re \cdot im} \]
      2. *-commutative5.3%

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in5.3%

        \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    4. Simplified5.3%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
    5. Taylor expanded in re around 0 29.7%

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

        \[\leadsto \color{blue}{-re \cdot im} \]
      2. distribute-rgt-neg-in29.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.05 \cdot 10^{+33}:\\ \;\;\;\;\sqrt{re \cdot \left(re \cdot 182.25\right)}\\ \mathbf{elif}\;im \leq 1.06 \cdot 10^{+130}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-im \cdot re\\ \end{array} \]

Alternative 15: 33.7% accurate, 77.0× speedup?

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

\\
-im \cdot re
\end{array}
Derivation
  1. Initial program 65.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 51.7%

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

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

      \[\leadsto -\color{blue}{im \cdot \sin re} \]
    3. distribute-rgt-neg-in51.7%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  4. Simplified51.7%

    \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  5. Taylor expanded in re around 0 36.1%

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

      \[\leadsto \color{blue}{-re \cdot im} \]
    2. distribute-rgt-neg-in36.1%

      \[\leadsto \color{blue}{re \cdot \left(-im\right)} \]
  7. Simplified36.1%

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

    \[\leadsto -im \cdot re \]

Alternative 16: 2.8% accurate, 308.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 65.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 51.7%

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

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

      \[\leadsto -\color{blue}{im \cdot \sin re} \]
    3. distribute-rgt-neg-in51.7%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  4. Simplified51.7%

    \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  5. Applied egg-rr2.7%

    \[\leadsto \color{blue}{-3} \]
  6. Final simplification2.7%

    \[\leadsto -3 \]

Alternative 17: 2.8% accurate, 308.0× speedup?

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

\\
-9.92290301275212 \cdot 10^{-8}
\end{array}
Derivation
  1. Initial program 65.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 51.7%

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

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

      \[\leadsto -\color{blue}{im \cdot \sin re} \]
    3. distribute-rgt-neg-in51.7%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  4. Simplified51.7%

    \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  5. Applied egg-rr2.8%

    \[\leadsto \color{blue}{-9.92290301275212 \cdot 10^{-8}} \]
  6. Final simplification2.8%

    \[\leadsto -9.92290301275212 \cdot 10^{-8} \]

Alternative 18: 15.3% accurate, 308.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 65.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 51.7%

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

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

      \[\leadsto -\color{blue}{im \cdot \sin re} \]
    3. distribute-rgt-neg-in51.7%

      \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  4. Simplified51.7%

    \[\leadsto \color{blue}{im \cdot \left(-\sin re\right)} \]
  5. Applied egg-rr15.0%

    \[\leadsto \color{blue}{0} \]
  6. Final simplification15.0%

    \[\leadsto 0 \]

Developer target: 99.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023189 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))