math.cos on complex, imaginary part

Percentage Accurate: 66.1% → 99.8%
Time: 10.8s
Alternatives: 12
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 12 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: 66.1% 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 -400 \lor \neg \left(t_0 \leq 0.2\right):\\ \;\;\;\;t_0 \cdot \left(\sin re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -400.0) (not (<= t_0 0.2)))
     (* t_0 (* (sin re) 0.5))
     (*
      (sin re)
      (+
       (- (* (pow im 5.0) -0.008333333333333333) im)
       (+
        (* (pow im 7.0) -0.0001984126984126984)
        (* (* im im) (* im -0.16666666666666666))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -400.0) || !(t_0 <= 0.2)) {
		tmp = t_0 * (sin(re) * 0.5);
	} else {
		tmp = sin(re) * (((pow(im, 5.0) * -0.008333333333333333) - im) + ((pow(im, 7.0) * -0.0001984126984126984) + ((im * im) * (im * -0.16666666666666666))));
	}
	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 <= (-400.0d0)) .or. (.not. (t_0 <= 0.2d0))) then
        tmp = t_0 * (sin(re) * 0.5d0)
    else
        tmp = sin(re) * ((((im ** 5.0d0) * (-0.008333333333333333d0)) - im) + (((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im * im) * (im * (-0.16666666666666666d0)))))
    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 <= -400.0) || !(t_0 <= 0.2)) {
		tmp = t_0 * (Math.sin(re) * 0.5);
	} else {
		tmp = Math.sin(re) * (((Math.pow(im, 5.0) * -0.008333333333333333) - im) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + ((im * im) * (im * -0.16666666666666666))));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -400.0) or not (t_0 <= 0.2):
		tmp = t_0 * (math.sin(re) * 0.5)
	else:
		tmp = math.sin(re) * (((math.pow(im, 5.0) * -0.008333333333333333) - im) + ((math.pow(im, 7.0) * -0.0001984126984126984) + ((im * im) * (im * -0.16666666666666666))))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -400.0) || !(t_0 <= 0.2))
		tmp = Float64(t_0 * Float64(sin(re) * 0.5));
	else
		tmp = Float64(sin(re) * Float64(Float64(Float64((im ^ 5.0) * -0.008333333333333333) - im) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64(Float64(im * im) * Float64(im * -0.16666666666666666)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -400.0) || ~((t_0 <= 0.2)))
		tmp = t_0 * (sin(re) * 0.5);
	else
		tmp = sin(re) * ((((im ^ 5.0) * -0.008333333333333333) - im) + (((im ^ 7.0) * -0.0001984126984126984) + ((im * im) * (im * -0.16666666666666666))));
	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, -400.0], N[Not[LessEqual[t$95$0, 0.2]], $MachinePrecision]], N[(t$95$0 * N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] - im), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -400 or 0.20000000000000001 < (-.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 -400 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.20000000000000001

    1. Initial program 35.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}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+99.8%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg99.8%

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in99.8%

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

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*99.8%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out99.8%

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*99.8%

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*99.8%

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{3} \cdot -0.16666666666666666\right)\right)} \]
    5. Step-by-step derivation
      1. add-log-exp99.5%

        \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)}\right)\right) \]
    6. Applied egg-rr99.5%

      \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)}\right)\right) \]
    7. Step-by-step derivation
      1. add-log-exp99.8%

        \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{{im}^{3} \cdot -0.16666666666666666}\right)\right) \]
      2. unpow399.8%

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

        \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)}\right)\right) \]
    8. Applied egg-rr99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -400 \lor \neg \left(e^{-im} - e^{im} \leq 0.2\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(\sin re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)\right)\right)\\ \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 -400 \lor \neg \left(t_0 \leq 0.02\right):\\ \;\;\;\;t_0 \cdot \left(\sin re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -400.0) (not (<= t_0 0.02)))
     (* t_0 (* (sin re) 0.5))
     (*
      (sin re)
      (+
       (* (pow im 5.0) -0.008333333333333333)
       (- (* (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 <= -400.0) || !(t_0 <= 0.02)) {
		tmp = t_0 * (sin(re) * 0.5);
	} else {
		tmp = sin(re) * ((pow(im, 5.0) * -0.008333333333333333) + ((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 <= (-400.0d0)) .or. (.not. (t_0 <= 0.02d0))) then
        tmp = t_0 * (sin(re) * 0.5d0)
    else
        tmp = sin(re) * (((im ** 5.0d0) * (-0.008333333333333333d0)) + (((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 <= -400.0) || !(t_0 <= 0.02)) {
		tmp = t_0 * (Math.sin(re) * 0.5);
	} else {
		tmp = Math.sin(re) * ((Math.pow(im, 5.0) * -0.008333333333333333) + ((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 <= -400.0) or not (t_0 <= 0.02):
		tmp = t_0 * (math.sin(re) * 0.5)
	else:
		tmp = math.sin(re) * ((math.pow(im, 5.0) * -0.008333333333333333) + ((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 <= -400.0) || !(t_0 <= 0.02))
		tmp = Float64(t_0 * Float64(sin(re) * 0.5));
	else
		tmp = Float64(sin(re) * Float64(Float64((im ^ 5.0) * -0.008333333333333333) + 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 <= -400.0) || ~((t_0 <= 0.02)))
		tmp = t_0 * (sin(re) * 0.5);
	else
		tmp = sin(re) * (((im ^ 5.0) * -0.008333333333333333) + (((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, -400.0], N[Not[LessEqual[t$95$0, 0.02]], $MachinePrecision]], N[(t$95$0 * N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -400 or 0.0200000000000000004 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.9%

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

    if -400 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0200000000000000004

    1. Initial program 35.1%

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

        \[\leadsto -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} \]
      2. associate-+r+99.8%

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

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

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      6. distribute-lft-neg-in99.8%

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

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

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      9. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      10. associate-*r*99.9%

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

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \color{blue}{\sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)} \]
      13. distribute-lft-out99.9%

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

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

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

Alternative 3: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -400 \lor \neg \left(t_0 \leq 0.001\right):\\ \;\;\;\;t_0 \cdot \left(\sin re \cdot 0.5\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 -400.0) (not (<= t_0 0.001)))
     (* t_0 (* (sin re) 0.5))
     (* (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 <= -400.0) || !(t_0 <= 0.001)) {
		tmp = t_0 * (sin(re) * 0.5);
	} 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 <= (-400.0d0)) .or. (.not. (t_0 <= 0.001d0))) then
        tmp = t_0 * (sin(re) * 0.5d0)
    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 <= -400.0) || !(t_0 <= 0.001)) {
		tmp = t_0 * (Math.sin(re) * 0.5);
	} 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 <= -400.0) or not (t_0 <= 0.001):
		tmp = t_0 * (math.sin(re) * 0.5)
	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 <= -400.0) || !(t_0 <= 0.001))
		tmp = Float64(t_0 * Float64(sin(re) * 0.5));
	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 <= -400.0) || ~((t_0 <= 0.001)))
		tmp = t_0 * (sin(re) * 0.5);
	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, -400.0], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(t$95$0 * N[(N[Sin[re], $MachinePrecision] * 0.5), $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 -400 \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;t_0 \cdot \left(\sin re \cdot 0.5\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)) < -400 or 1e-3 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.9%

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

    if -400 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1e-3

    1. Initial program 34.7%

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

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

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

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

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

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

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

      \[\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 -400 \lor \neg \left(e^{-im} - e^{im} \leq 0.001\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(\sin re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 4: 99.3% accurate, 0.5× speedup?

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

\\
\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 65.2%

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

    \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
  3. Step-by-step derivation
    1. associate-+r+95.5%

      \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
    2. +-commutative95.5%

      \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
    3. +-commutative95.5%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    4. mul-1-neg95.5%

      \[\leadsto \left(\color{blue}{\left(-\sin re \cdot im\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    5. *-commutative95.5%

      \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    6. distribute-lft-neg-in95.5%

      \[\leadsto \left(\color{blue}{\left(-im\right) \cdot \sin re} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    7. *-commutative95.5%

      \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    8. associate-*r*95.5%

      \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    9. distribute-rgt-out95.5%

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    10. *-commutative95.5%

      \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    11. associate-*r*95.5%

      \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
    12. *-commutative95.5%

      \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
    13. associate-*r*95.5%

      \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) \]
  4. Simplified95.5%

    \[\leadsto \color{blue}{\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{3} \cdot -0.16666666666666666\right)\right)} \]
  5. Step-by-step derivation
    1. add-log-exp99.0%

      \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)}\right)\right) \]
  6. Applied egg-rr99.0%

    \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \color{blue}{\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)}\right)\right) \]
  7. Final simplification99.0%

    \[\leadsto \sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + \log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right)\right)\right) \]

Alternative 5: 95.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -8 \cdot 10^{+54} \lor \neg \left(im \leq 1.1 \cdot 10^{+44}\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \left(-im\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -8e+54) (not (<= im 1.1e+44)))
   (* -0.0001984126984126984 (* (sin re) (pow im 7.0)))
   (log1p (expm1 (* (sin re) (- im))))))
double code(double re, double im) {
	double tmp;
	if ((im <= -8e+54) || !(im <= 1.1e+44)) {
		tmp = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
	} else {
		tmp = log1p(expm1((sin(re) * -im)));
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if ((im <= -8e+54) || !(im <= 1.1e+44)) {
		tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
	} else {
		tmp = Math.log1p(Math.expm1((Math.sin(re) * -im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -8e+54) or not (im <= 1.1e+44):
		tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0))
	else:
		tmp = math.log1p(math.expm1((math.sin(re) * -im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -8e+54) || !(im <= 1.1e+44))
		tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0)));
	else
		tmp = log1p(expm1(Float64(sin(re) * Float64(-im))));
	end
	return tmp
end
code[re_, im_] := If[Or[LessEqual[im, -8e+54], N[Not[LessEqual[im, 1.1e+44]], $MachinePrecision]], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -8 \cdot 10^{+54} \lor \neg \left(im \leq 1.1 \cdot 10^{+44}\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -8.0000000000000006e54 or 1.09999999999999998e44 < 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.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg100.0%

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in100.0%

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

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*100.0%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*100.0%

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*100.0%

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

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

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

    if -8.0000000000000006e54 < im < 1.09999999999999998e44

    1. Initial program 41.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
    6. Applied egg-rr95.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8 \cdot 10^{+54} \lor \neg \left(im \leq 1.1 \cdot 10^{+44}\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \left(-im\right)\right)\right)\\ \end{array} \]

Alternative 6: 90.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2 \cdot 10^{+97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -75000000:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq 3.3:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
   (if (<= im -2e+97)
     t_0
     (if (<= im -75000000.0)
       (* -0.0001984126984126984 (* re (pow im 7.0)))
       (if (<= im 3.3) (* (sin re) (- im)) t_0)))))
double code(double re, double im) {
	double t_0 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2e+97) {
		tmp = t_0;
	} else if (im <= -75000000.0) {
		tmp = -0.0001984126984126984 * (re * pow(im, 7.0));
	} else if (im <= 3.3) {
		tmp = sin(re) * -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-0.008333333333333333d0) * (sin(re) * (im ** 5.0d0))
    if (im <= (-2d+97)) then
        tmp = t_0
    else if (im <= (-75000000.0d0)) then
        tmp = (-0.0001984126984126984d0) * (re * (im ** 7.0d0))
    else if (im <= 3.3d0) then
        tmp = sin(re) * -im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2e+97) {
		tmp = t_0;
	} else if (im <= -75000000.0) {
		tmp = -0.0001984126984126984 * (re * Math.pow(im, 7.0));
	} else if (im <= 3.3) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0))
	tmp = 0
	if im <= -2e+97:
		tmp = t_0
	elif im <= -75000000.0:
		tmp = -0.0001984126984126984 * (re * math.pow(im, 7.0))
	elif im <= 3.3:
		tmp = math.sin(re) * -im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2e+97)
		tmp = t_0;
	elseif (im <= -75000000.0)
		tmp = Float64(-0.0001984126984126984 * Float64(re * (im ^ 7.0)));
	elseif (im <= 3.3)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.008333333333333333 * (sin(re) * (im ^ 5.0));
	tmp = 0.0;
	if (im <= -2e+97)
		tmp = t_0;
	elseif (im <= -75000000.0)
		tmp = -0.0001984126984126984 * (re * (im ^ 7.0));
	elseif (im <= 3.3)
		tmp = sin(re) * -im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2e+97], t$95$0, If[LessEqual[im, -75000000.0], N[(-0.0001984126984126984 * N[(re * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2 \cdot 10^{+97}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -75000000:\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.0000000000000001e97 or 3.2999999999999998 < 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 91.6%

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

        \[\leadsto -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} \]
      2. associate-+r+91.6%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      4. mul-1-neg91.6%

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      6. distribute-lft-neg-in91.6%

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

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      8. associate-*r*91.6%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      9. distribute-rgt-out91.6%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) \]
      10. associate-*r*91.6%

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

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

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \color{blue}{\sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)} \]
      13. distribute-lft-out91.6%

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

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

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

        \[\leadsto -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)} \]
    7. Simplified91.5%

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

    if -2.0000000000000001e97 < im < -7.5e7

    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 74.8%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+74.8%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative74.8%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative74.8%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg74.8%

        \[\leadsto \left(\color{blue}{\left(-\sin re \cdot im\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      5. *-commutative74.8%

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in74.8%

        \[\leadsto \left(\color{blue}{\left(-im\right) \cdot \sin re} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      7. *-commutative74.8%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*74.8%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out74.8%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      10. *-commutative74.8%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*74.8%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      12. *-commutative74.8%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*74.8%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) \]
    4. Simplified74.8%

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*74.8%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \sin re\right) \cdot {im}^{7}} \]
      2. *-commutative74.8%

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \sin re\right)} \]
    7. Simplified74.8%

      \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \sin re\right)} \]
    8. Taylor expanded in re around 0 87.1%

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

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

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

    if -7.5e7 < im < 3.2999999999999998

    1. Initial program 36.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+97}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -75000000:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq 3.3:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 7: 92.6% accurate, 1.5× speedup?

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+90.5%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative90.5%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative90.5%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg90.5%

        \[\leadsto \left(\color{blue}{\left(-\sin re \cdot im\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      5. *-commutative90.5%

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in90.5%

        \[\leadsto \left(\color{blue}{\left(-im\right) \cdot \sin re} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      7. *-commutative90.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*90.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out90.5%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      10. *-commutative90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      12. *-commutative90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) \]
    4. Simplified90.5%

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

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

    if -5.5999999999999996 < im < 5.5

    1. Initial program 36.0%

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

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

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

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

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

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

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

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

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

Alternative 8: 92.4% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.2 \lor \neg \left(im \leq 4.1\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -4.20000000000000018 or 4.0999999999999996 < 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 90.5%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+90.5%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative90.5%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative90.5%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg90.5%

        \[\leadsto \left(\color{blue}{\left(-\sin re \cdot im\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      5. *-commutative90.5%

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in90.5%

        \[\leadsto \left(\color{blue}{\left(-im\right) \cdot \sin re} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      7. *-commutative90.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*90.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out90.5%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      10. *-commutative90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      12. *-commutative90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*90.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) \]
    4. Simplified90.5%

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

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

    if -4.20000000000000018 < im < 4.0999999999999996

    1. Initial program 36.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.2 \lor \neg \left(im \leq 4.1\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \end{array} \]

Alternative 9: 82.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -32000000 \lor \neg \left(im \leq 850\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -32000000.0) (not (<= im 850.0)))
   (* -0.0001984126984126984 (* re (pow im 7.0)))
   (* (sin re) (- im))))
double code(double re, double im) {
	double tmp;
	if ((im <= -32000000.0) || !(im <= 850.0)) {
		tmp = -0.0001984126984126984 * (re * pow(im, 7.0));
	} else {
		tmp = sin(re) * -im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-32000000.0d0)) .or. (.not. (im <= 850.0d0))) then
        tmp = (-0.0001984126984126984d0) * (re * (im ** 7.0d0))
    else
        tmp = sin(re) * -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -32000000.0) || !(im <= 850.0)) {
		tmp = -0.0001984126984126984 * (re * Math.pow(im, 7.0));
	} else {
		tmp = Math.sin(re) * -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -32000000.0) or not (im <= 850.0):
		tmp = -0.0001984126984126984 * (re * math.pow(im, 7.0))
	else:
		tmp = math.sin(re) * -im
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -32000000.0) || !(im <= 850.0))
		tmp = Float64(-0.0001984126984126984 * Float64(re * (im ^ 7.0)));
	else
		tmp = Float64(sin(re) * Float64(-im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -32000000.0) || ~((im <= 850.0)))
		tmp = -0.0001984126984126984 * (re * (im ^ 7.0));
	else
		tmp = sin(re) * -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -32000000.0], N[Not[LessEqual[im, 850.0]], $MachinePrecision]], N[(-0.0001984126984126984 * N[(re * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -32000000 \lor \neg \left(im \leq 850\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.2e7 or 850 < 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 92.5%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+92.5%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right)} \]
      2. +-commutative92.5%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right)} \]
      3. +-commutative92.5%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin re \cdot im\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      4. mul-1-neg92.5%

        \[\leadsto \left(\color{blue}{\left(-\sin re \cdot im\right)} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      5. *-commutative92.5%

        \[\leadsto \left(\left(-\color{blue}{im \cdot \sin re}\right) + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      6. distribute-lft-neg-in92.5%

        \[\leadsto \left(\color{blue}{\left(-im\right) \cdot \sin re} + -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      7. *-commutative92.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + -0.008333333333333333 \cdot \color{blue}{\left({im}^{5} \cdot \sin re\right)}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      8. associate-*r*92.5%

        \[\leadsto \left(\left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      9. distribute-rgt-out92.5%

        \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right)} + \left(-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right) + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      10. *-commutative92.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot \sin re\right)} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      11. associate-*r*92.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re} + -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\right) \]
      12. *-commutative92.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)}\right) \]
      13. associate-*r*92.5%

        \[\leadsto \sin re \cdot \left(\left(-im\right) + -0.008333333333333333 \cdot {im}^{5}\right) + \left(\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re}\right) \]
    4. Simplified92.5%

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*92.5%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot \sin re\right) \cdot {im}^{7}} \]
      2. *-commutative92.5%

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \sin re\right)} \]
    7. Simplified92.5%

      \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \sin re\right)} \]
    8. Taylor expanded in re around 0 75.6%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)} \]
    9. Step-by-step derivation
      1. *-commutative75.6%

        \[\leadsto -0.0001984126984126984 \cdot \color{blue}{\left({im}^{7} \cdot re\right)} \]
    10. Simplified75.6%

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

    if -3.2e7 < im < 850

    1. Initial program 37.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -32000000 \lor \neg \left(im \leq 850\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \end{array} \]

Alternative 10: 53.6% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8 \cdot 10^{+18}:\\
\;\;\;\;im \cdot \left(-re\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

    if -4.8e18 < im

    1. Initial program 55.5%

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

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

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

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

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

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

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

Alternative 11: 32.6% accurate, 77.0× speedup?

\[\begin{array}{l} \\ im \cdot \left(-re\right) \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(im * Float64(-re))
end
function tmp = code(re, im)
	tmp = im * -re;
end
code[re_, im_] := N[(im * (-re)), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 3.2% accurate, 102.7× speedup?

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

\\
re \cdot 13.5
\end{array}
Derivation
  1. Initial program 65.2%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Applied egg-rr3.5%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{27} \]
  3. Taylor expanded in re around 0 3.8%

    \[\leadsto \color{blue}{13.5 \cdot re} \]
  4. Step-by-step derivation
    1. *-commutative3.8%

      \[\leadsto \color{blue}{re \cdot 13.5} \]
  5. Simplified3.8%

    \[\leadsto \color{blue}{re \cdot 13.5} \]
  6. Final simplification3.8%

    \[\leadsto re \cdot 13.5 \]

Developer target: 99.8% 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 2023182 
(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))))