math.cos on complex, imaginary part

Percentage Accurate: 65.6% → 99.6%
Time: 8.0s
Alternatives: 11
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 11 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: 65.6% 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.6% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\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)\\


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

    1. Initial program 31.0%

      \[\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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -5 \cdot 10^{+66} \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-5}\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\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)\\ \end{array} \]

Alternative 2: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

    if -0.050000000000000003 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 2.00000000000000016e-5

    1. Initial program 30.4%

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

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

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

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

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

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

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

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

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

Alternative 3: 97.5% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.05 \cdot 10^{+44}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.04999999999999993e44 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)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

    if -1.04999999999999993e44 < im < -0.0012999999999999999 or 0.0015 < im < 1.09999999999999998e44

    1. Initial program 99.7%

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

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

    if -0.0012999999999999999 < im < 0.0015

    1. Initial program 30.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.05 \cdot 10^{+44}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.0013:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 0.0015:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 4: 97.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ t_1 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -1.05 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.095:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.023:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (* (- (exp (- im)) (exp im)) re)))
        (t_1 (* -0.0001984126984126984 (* (sin re) (pow im 7.0)))))
   (if (<= im -1.05e+44)
     t_1
     (if (<= im -0.095)
       t_0
       (if (<= im 0.023)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	double t_1 = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
	double tmp;
	if (im <= -1.05e+44) {
		tmp = t_1;
	} else if (im <= -0.095) {
		tmp = t_0;
	} else if (im <= 0.023) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * ((exp(-im) - exp(im)) * re)
    t_1 = (-0.0001984126984126984d0) * (sin(re) * (im ** 7.0d0))
    if (im <= (-1.05d+44)) then
        tmp = t_1
    else if (im <= (-0.095d0)) then
        tmp = t_0
    else if (im <= 0.023d0) then
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 1.1d+44) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
	double t_1 = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -1.05e+44) {
		tmp = t_1;
	} else if (im <= -0.095) {
		tmp = t_0;
	} else if (im <= 0.023) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * ((math.exp(-im) - math.exp(im)) * re)
	t_1 = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -1.05e+44:
		tmp = t_1
	elif im <= -0.095:
		tmp = t_0
	elif im <= 0.023:
		tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 1.1e+44:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re))
	t_1 = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -1.05e+44)
		tmp = t_1;
	elseif (im <= -0.095)
		tmp = t_0;
	elseif (im <= 0.023)
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	t_1 = -0.0001984126984126984 * (sin(re) * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -1.05e+44)
		tmp = t_1;
	elseif (im <= -0.095)
		tmp = t_0;
	elseif (im <= 0.023)
		tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.05e+44], t$95$1, If[LessEqual[im, -0.095], t$95$0, If[LessEqual[im, 0.023], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.05 \cdot 10^{+44}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.04999999999999993e44 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)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

    if -1.04999999999999993e44 < im < -0.095000000000000001 or 0.023 < im < 1.09999999999999998e44

    1. Initial program 99.7%

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

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

    if -0.095000000000000001 < im < 0.023

    1. Initial program 30.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.05 \cdot 10^{+44}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.095:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 0.023:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 5: 92.6% accurate, 1.5× speedup?

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

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

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


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

      \[\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+87.2%

        \[\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. +-commutative87.2%

        \[\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. +-commutative87.2%

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

        \[\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. *-commutative87.2%

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

        \[\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. *-commutative87.2%

        \[\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*87.2%

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

        \[\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. *-commutative87.2%

        \[\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*87.2%

        \[\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. *-commutative87.2%

        \[\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*87.2%

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

      \[\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 87.2%

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

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

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

    if -4.20000000000000018 < im < 4.20000000000000018

    1. Initial program 31.0%

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

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

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

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

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

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

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

Alternative 6: 81.6% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := -0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\
t_1 := {im}^{7} \cdot \left(re \cdot \left(-0.0001984126984126984 + 3.306878306878307 \cdot 10^{-5} \cdot \left(re \cdot re\right)\right)\right)\\
\mathbf{if}\;im \leq -2.3 \cdot 10^{+95}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -5 \cdot 10^{+50}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -5.3 \cdot 10^{+14}:\\
\;\;\;\;t_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.29999999999999997e95 or -5e50 < im < -5.3e14

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

      \[\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+91.1%

        \[\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. +-commutative91.1%

        \[\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. +-commutative91.1%

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

        \[\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. *-commutative91.1%

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

        \[\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. *-commutative91.1%

        \[\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*91.1%

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

        \[\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. *-commutative91.1%

        \[\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*91.1%

        \[\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. *-commutative91.1%

        \[\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*91.1%

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

      \[\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 91.1%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right) + 3.306878306878307 \cdot 10^{-5} \cdot \left({re}^{3} \cdot {im}^{7}\right)} \]
    9. Step-by-step derivation
      1. associate-*r*2.0%

        \[\leadsto \color{blue}{\left(-0.0001984126984126984 \cdot re\right) \cdot {im}^{7}} + 3.306878306878307 \cdot 10^{-5} \cdot \left({re}^{3} \cdot {im}^{7}\right) \]
      2. *-commutative2.0%

        \[\leadsto \color{blue}{\left(re \cdot -0.0001984126984126984\right)} \cdot {im}^{7} + 3.306878306878307 \cdot 10^{-5} \cdot \left({re}^{3} \cdot {im}^{7}\right) \]
      3. associate-*r*2.0%

        \[\leadsto \left(re \cdot -0.0001984126984126984\right) \cdot {im}^{7} + \color{blue}{\left(3.306878306878307 \cdot 10^{-5} \cdot {re}^{3}\right) \cdot {im}^{7}} \]
      4. distribute-rgt-out87.2%

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(re \cdot -0.0001984126984126984 + 3.306878306878307 \cdot 10^{-5} \cdot {re}^{3}\right)} \]
      5. *-commutative87.2%

        \[\leadsto {im}^{7} \cdot \left(\color{blue}{-0.0001984126984126984 \cdot re} + 3.306878306878307 \cdot 10^{-5} \cdot {re}^{3}\right) \]
      6. unpow387.2%

        \[\leadsto {im}^{7} \cdot \left(-0.0001984126984126984 \cdot re + 3.306878306878307 \cdot 10^{-5} \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot re\right)}\right) \]
      7. unpow287.2%

        \[\leadsto {im}^{7} \cdot \left(-0.0001984126984126984 \cdot re + 3.306878306878307 \cdot 10^{-5} \cdot \left(\color{blue}{{re}^{2}} \cdot re\right)\right) \]
      8. associate-*r*87.2%

        \[\leadsto {im}^{7} \cdot \left(-0.0001984126984126984 \cdot re + \color{blue}{\left(3.306878306878307 \cdot 10^{-5} \cdot {re}^{2}\right) \cdot re}\right) \]
      9. distribute-rgt-out87.2%

        \[\leadsto {im}^{7} \cdot \color{blue}{\left(re \cdot \left(-0.0001984126984126984 + 3.306878306878307 \cdot 10^{-5} \cdot {re}^{2}\right)\right)} \]
      10. unpow287.2%

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

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

    if -2.29999999999999997e95 < im < -5e50 or 4.8e17 < 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.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+91.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. +-commutative91.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. +-commutative91.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-neg91.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. *-commutative91.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-in91.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. *-commutative91.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*91.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-out91.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. *-commutative91.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*91.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. *-commutative91.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*91.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. Simplified91.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 re around 0 78.8%

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

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

    if -5.3e14 < im < 4.8e17

    1. Initial program 34.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.3 \cdot 10^{+95}:\\ \;\;\;\;{im}^{7} \cdot \left(re \cdot \left(-0.0001984126984126984 + 3.306878306878307 \cdot 10^{-5} \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{elif}\;im \leq -5 \cdot 10^{+50}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -5.3 \cdot 10^{+14}:\\ \;\;\;\;{im}^{7} \cdot \left(re \cdot \left(-0.0001984126984126984 + 3.306878306878307 \cdot 10^{-5} \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{elif}\;im \leq 4.8 \cdot 10^{+17}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 7: 82.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -30000 \lor \neg \left(im \leq 4.5 \cdot 10^{+17}\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3e4 or 4.5e17 < 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 89.1%

      \[\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+89.1%

        \[\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. +-commutative89.1%

        \[\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. +-commutative89.1%

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

        \[\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. *-commutative89.1%

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

        \[\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. *-commutative89.1%

        \[\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*89.1%

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

        \[\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. *-commutative89.1%

        \[\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*89.1%

        \[\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. *-commutative89.1%

        \[\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*89.1%

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

      \[\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 re around 0 73.0%

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

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

    if -3e4 < im < 4.5e17

    1. Initial program 32.6%

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

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

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

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

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

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

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

Alternative 8: 56.1% accurate, 2.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\sqrt{0.5 \cdot \left(27 \cdot re\right)} \cdot \sqrt{0.5 \cdot \left(27 \cdot re\right)}} \]
      2. sqrt-unprod11.7%

        \[\leadsto \color{blue}{\sqrt{\left(0.5 \cdot \left(27 \cdot re\right)\right) \cdot \left(0.5 \cdot \left(27 \cdot re\right)\right)}} \]
      3. associate-*r*11.7%

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

        \[\leadsto \sqrt{\left(\left(0.5 \cdot 27\right) \cdot re\right) \cdot \color{blue}{\left(\left(0.5 \cdot 27\right) \cdot re\right)}} \]
      5. swap-sqr11.7%

        \[\leadsto \sqrt{\color{blue}{\left(\left(0.5 \cdot 27\right) \cdot \left(0.5 \cdot 27\right)\right) \cdot \left(re \cdot re\right)}} \]
      6. metadata-eval11.7%

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

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

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

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

    if -5.3e14 < im < 2.4999999999999999e32

    1. Initial program 36.2%

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

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

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

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

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

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

    if 2.4999999999999999e32 < im

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left(-im\right)} \]
    5. Simplified23.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.3 \cdot 10^{+14}:\\ \;\;\;\;\sqrt{\left(re \cdot re\right) \cdot 182.25}\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+32}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \]

Alternative 9: 53.9% accurate, 2.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 2.39999999999999982e31

    1. Initial program 57.9%

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

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

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

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

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

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

    if 2.39999999999999982e31 < im

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left(-im\right)} \]
    5. Simplified23.9%

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

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

Alternative 10: 32.8% 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 67.1%

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

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

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

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

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

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

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

Alternative 11: 14.5% accurate, 308.0× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\right)\right)} \]
    2. expm1-udef33.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\right)} - 1} \]
    3. add-sqr-sqrt16.0%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{\color{blue}{\sqrt{-im} \cdot \sqrt{-im}}} - e^{im}\right) \cdot re\right)\right)} - 1 \]
    4. sqrt-unprod24.1%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{\color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}} - e^{im}\right) \cdot re\right)\right)} - 1 \]
    5. sqr-neg24.1%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{\sqrt{\color{blue}{im \cdot im}}} - e^{im}\right) \cdot re\right)\right)} - 1 \]
    6. sqrt-unprod8.2%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{\color{blue}{\sqrt{im} \cdot \sqrt{im}}} - e^{im}\right) \cdot re\right)\right)} - 1 \]
    7. add-sqr-sqrt14.0%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{\color{blue}{im}} - e^{im}\right) \cdot re\right)\right)} - 1 \]
  4. Applied egg-rr14.0%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{im} - e^{im}\right) \cdot re\right)\right)} - 1} \]
  5. Step-by-step derivation
    1. expm1-def14.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \left(\left(e^{im} - e^{im}\right) \cdot re\right)\right)\right)} \]
    2. expm1-log1p14.0%

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

      \[\leadsto 0.5 \cdot \left(\color{blue}{0} \cdot re\right) \]
    4. mul0-lft14.4%

      \[\leadsto 0.5 \cdot \color{blue}{0} \]
    5. metadata-eval14.4%

      \[\leadsto \color{blue}{0} \]
  6. Simplified14.4%

    \[\leadsto \color{blue}{0} \]
  7. Final simplification14.4%

    \[\leadsto 0 \]

Developer target: 99.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023240 
(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))))