math.cos on complex, imaginary part

Percentage Accurate: 65.9% → 99.5%
Time: 10.7s
Alternatives: 12
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 65.9% 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.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot t_0\\ \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 (- INFINITY)) (not (<= t_0 2e-6)))
     (* (* 0.5 (sin re)) t_0)
     (* (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 <= -((double) INFINITY)) || !(t_0 <= 2e-6)) {
		tmp = (0.5 * sin(re)) * t_0;
	} else {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e-6)) {
		tmp = (0.5 * Math.sin(re)) * t_0;
	} 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 <= -math.inf) or not (t_0 <= 2e-6):
		tmp = (0.5 * math.sin(re)) * t_0
	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 <= Float64(-Inf)) || !(t_0 <= 2e-6))
		tmp = Float64(Float64(0.5 * sin(re)) * t_0);
	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 <= -Inf) || ~((t_0 <= 2e-6)))
		tmp = (0.5 * sin(re)) * t_0;
	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, (-Infinity)], N[Not[LessEqual[t$95$0, 2e-6]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $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 -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot t_0\\

\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)) < -inf.0 or 1.99999999999999991e-6 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.9%

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

    if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999991e-6

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

Alternative 2: 96.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_0\\ \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 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
   (if (<= t_0 (- INFINITY))
     t_0
     (*
      (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 = (0.5 * sin(re)) * (exp(-im) - exp(im));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_0;
	} 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;
}
public static double code(double re, double im) {
	double t_0 = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} 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 = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_0
	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(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_0;
	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 = (0.5 * sin(re)) * (exp(-im) - exp(im));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_0;
	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[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$0, 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 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_0\\

\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 (*.f64 1/2 (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

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

    if -inf.0 < (*.f64 (*.f64 1/2 (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)))

    1. Initial program 53.9%

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

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

        \[\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. +-commutative98.3%

        \[\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. +-commutative98.3%

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

        \[\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. *-commutative98.3%

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

        \[\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. *-commutative98.3%

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

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

        \[\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. *-commutative98.3%

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

        \[\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. *-commutative98.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\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 3: 95.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot t_0\\


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

    1. Initial program 53.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0100000000000000002 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

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

Alternative 4: 94.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.3000000000000001e36 or 2.9e10 < 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 97.6%

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

        \[\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. +-commutative97.6%

        \[\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. +-commutative97.6%

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

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

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

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

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

    if -1.3000000000000001e36 < im < 2.9e10

    1. Initial program 37.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 95.8% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq -0.0027:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(e^{-im} - e^{im}\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 or 5.5999999999999996 < 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 97.6%

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

        \[\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. +-commutative97.6%

        \[\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. +-commutative97.6%

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

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

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

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

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

    if -1.09999999999999998e44 < im < -0.0027000000000000001

    1. Initial program 98.9%

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

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

    if -0.0027000000000000001 < im < 5.5999999999999996

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

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

Alternative 6: 95.6% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq -0.0025:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(e^{-im} - e^{im}\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 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 97.6%

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

        \[\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. +-commutative97.6%

        \[\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. +-commutative97.6%

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

        \[\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. *-commutative97.6%

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

        \[\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. *-commutative97.6%

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

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

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

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

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

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

    if -1.09999999999999998e44 < im < -0.00250000000000000005

    1. Initial program 98.9%

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

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

    if -0.00250000000000000005 < 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 99.7%

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

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

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

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

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

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

Alternative 7: 93.0% accurate, 1.5× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.0999999999999996 < im < 4.20000000000000018

    1. Initial program 32.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 simplification94.5%

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

Alternative 8: 82.0% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.2 \cdot 10^{+21} \lor \neg \left(im \leq 1.85 \cdot 10^{+56}\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.2e21 or 1.84999999999999998e56 < 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 96.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+96.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. +-commutative96.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. +-commutative96.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-neg96.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. *-commutative96.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-in96.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. *-commutative96.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*96.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-out96.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. *-commutative96.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*96.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. *-commutative96.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*96.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. Simplified96.8%

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

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

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

    if -1.2e21 < im < 1.84999999999999998e56

    1. Initial program 37.0%

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

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

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

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

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

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

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

Alternative 9: 56.6% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+27} \lor \neg \left(im \leq 8 \cdot 10^{+68}\right):\\
\;\;\;\;re \cdot \left(-im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.49999999999999966e27 or 7.99999999999999962e68 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -5.49999999999999966e27 < im < 7.99999999999999962e68

    1. Initial program 39.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+27} \lor \neg \left(im \leq 8 \cdot 10^{+68}\right):\\ \;\;\;\;re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \end{array} \]

Alternative 10: 55.8% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.45 \cdot 10^{+37}:\\
\;\;\;\;\sqrt{re \cdot \left(re \cdot 9.5367431640625 \cdot 10^{-7}\right)}\\

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

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


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

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(0.5 \cdot \left(0.001953125 \cdot re\right)\right)\right)} \]
      2. associate-*r*24.2%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(0.5 \cdot 0.001953125\right) \cdot re}\right)\right) \]
      3. metadata-eval24.2%

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

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

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

        \[\leadsto \color{blue}{\sqrt{0.0009765625 \cdot re} \cdot \sqrt{0.0009765625 \cdot re}} \]
      3. sqrt-unprod14.4%

        \[\leadsto \color{blue}{\sqrt{\left(0.0009765625 \cdot re\right) \cdot \left(0.0009765625 \cdot re\right)}} \]
      4. swap-sqr14.4%

        \[\leadsto \sqrt{\color{blue}{\left(0.0009765625 \cdot 0.0009765625\right) \cdot \left(re \cdot re\right)}} \]
      5. metadata-eval14.4%

        \[\leadsto \sqrt{\color{blue}{9.5367431640625 \cdot 10^{-7}} \cdot \left(re \cdot re\right)} \]
    7. Applied egg-rr14.4%

      \[\leadsto \color{blue}{\sqrt{9.5367431640625 \cdot 10^{-7} \cdot \left(re \cdot re\right)}} \]
    8. Step-by-step derivation
      1. associate-*r*14.4%

        \[\leadsto \sqrt{\color{blue}{\left(9.5367431640625 \cdot 10^{-7} \cdot re\right) \cdot re}} \]
    9. Simplified14.4%

      \[\leadsto \color{blue}{\sqrt{\left(9.5367431640625 \cdot 10^{-7} \cdot re\right) \cdot re}} \]

    if -3.4499999999999998e37 < im < 7.60000000000000055e69

    1. Initial program 40.5%

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

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

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

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

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

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

    if 7.60000000000000055e69 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.45 \cdot 10^{+37}:\\ \;\;\;\;\sqrt{re \cdot \left(re \cdot 9.5367431640625 \cdot 10^{-7}\right)}\\ \mathbf{elif}\;im \leq 7.6 \cdot 10^{+69}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(-im\right)\\ \end{array} \]

Alternative 11: 32.9% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 3.3% accurate, 102.7× speedup?

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

\\
re \cdot 0.0009765625
\end{array}
Derivation
  1. Initial program 66.5%

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

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

    \[\leadsto 0.5 \cdot \left(\color{blue}{0.001953125} \cdot re\right) \]
  4. Taylor expanded in re around 0 3.5%

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

      \[\leadsto \color{blue}{re \cdot 0.0009765625} \]
  6. Simplified3.5%

    \[\leadsto \color{blue}{re \cdot 0.0009765625} \]
  7. Final simplification3.5%

    \[\leadsto re \cdot 0.0009765625 \]

Developer target: 99.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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