math.cos on complex, imaginary part

Percentage Accurate: 64.9% → 99.6%
Time: 10.2s
Alternatives: 14
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 14 alternatives:

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

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

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

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

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


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

    1. Initial program 29.5%

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

      \[\leadsto \color{blue}{-0.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. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{3}} + \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(\sin re \cdot -0.16666666666666666\right)} \cdot {im}^{3} + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) + -1 \cdot \left(\sin re \cdot im\right)\right) \]
      3. associate-*l*99.8%

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg99.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 + \left({im}^{5} \cdot -0.008333333333333333 - im\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 \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-12}\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 + \left({im}^{5} \cdot -0.008333333333333333 - im\right)\right)\\ \end{array} \]

Alternative 2: 99.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.002 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\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.002) (not (<= t_0 2e-12)))
     (* 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.002) || !(t_0 <= 2e-12)) {
		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.002d0)) .or. (.not. (t_0 <= 2d-12))) 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.002) || !(t_0 <= 2e-12)) {
		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.002) or not (t_0 <= 2e-12):
		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.002) || !(t_0 <= 2e-12))
		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.002) || ~((t_0 <= 2e-12)))
		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.002], N[Not[LessEqual[t$95$0, 2e-12]], $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.002 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\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)) < -2e-3 or 1.99999999999999996e-12 < (-.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 -2e-3 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999996e-12

    1. Initial program 29.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 -0.002 \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-12}\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: 93.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -2.2 \cdot 10^{+70}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -130:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 5:\\ \;\;\;\;\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 (* (sin re) (* (pow im 5.0) -0.008333333333333333))))
   (if (<= im -2.2e+70)
     t_0
     (if (<= im -130.0)
       (* (- (exp (- im)) (exp im)) (* 0.5 re))
       (if (<= im 5.0)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         t_0)))))
double code(double re, double im) {
	double t_0 = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
	double tmp;
	if (im <= -2.2e+70) {
		tmp = t_0;
	} else if (im <= -130.0) {
		tmp = (exp(-im) - exp(im)) * (0.5 * re);
	} else if (im <= 5.0) {
		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 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
    if (im <= (-2.2d+70)) then
        tmp = t_0
    else if (im <= (-130.0d0)) then
        tmp = (exp(-im) - exp(im)) * (0.5d0 * re)
    else if (im <= 5.0d0) 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 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
	double tmp;
	if (im <= -2.2e+70) {
		tmp = t_0;
	} else if (im <= -130.0) {
		tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
	} else if (im <= 5.0) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333)
	tmp = 0
	if im <= -2.2e+70:
		tmp = t_0
	elif im <= -130.0:
		tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re)
	elif im <= 5.0:
		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(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -2.2e+70)
		tmp = t_0;
	elseif (im <= -130.0)
		tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re));
	elseif (im <= 5.0)
		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 = sin(re) * ((im ^ 5.0) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -2.2e+70)
		tmp = t_0;
	elseif (im <= -130.0)
		tmp = (exp(-im) - exp(im)) * (0.5 * re);
	elseif (im <= 5.0)
		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[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.2e+70], t$95$0, If[LessEqual[im, -130.0], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.0], 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 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -2.2 \cdot 10^{+70}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 5:\\
\;\;\;\;\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 < -2.20000000000000001e70 or 5 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 93.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. associate-*r*93.8%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg93.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.20000000000000001e70 < im < -130

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

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

    if -130 < im < 5

    1. Initial program 30.6%

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

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

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

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

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

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

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

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

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

Alternative 4: 90.2% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 83.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. associate-*r*83.8%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5 < im < 5

    1. Initial program 30.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 89.9% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.3\right):\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 83.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. associate-*r*83.8%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2999999999999998 < im < 3.2999999999999998

    1. Initial program 30.0%

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

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

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

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

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

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

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

Alternative 6: 82.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.2 \cdot 10^{+18}:\\
\;\;\;\;re \cdot \sqrt{{im}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}\\

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

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


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

    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.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. associate-*r*90.8%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re} \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right) \]
    9. Step-by-step derivation
      1. add-sqr-sqrt66.4%

        \[\leadsto re \cdot \color{blue}{\left(\sqrt{-0.008333333333333333 \cdot {im}^{5}} \cdot \sqrt{-0.008333333333333333 \cdot {im}^{5}}\right)} \]
      2. sqrt-unprod71.0%

        \[\leadsto re \cdot \color{blue}{\sqrt{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)}} \]
      3. *-commutative71.0%

        \[\leadsto re \cdot \sqrt{\color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)} \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)} \]
      4. *-commutative71.0%

        \[\leadsto re \cdot \sqrt{\left({im}^{5} \cdot -0.008333333333333333\right) \cdot \color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)}} \]
      5. swap-sqr71.0%

        \[\leadsto re \cdot \sqrt{\color{blue}{\left({im}^{5} \cdot {im}^{5}\right) \cdot \left(-0.008333333333333333 \cdot -0.008333333333333333\right)}} \]
      6. pow-prod-up71.0%

        \[\leadsto re \cdot \sqrt{\color{blue}{{im}^{\left(5 + 5\right)}} \cdot \left(-0.008333333333333333 \cdot -0.008333333333333333\right)} \]
      7. metadata-eval71.0%

        \[\leadsto re \cdot \sqrt{{im}^{\color{blue}{10}} \cdot \left(-0.008333333333333333 \cdot -0.008333333333333333\right)} \]
      8. metadata-eval71.0%

        \[\leadsto re \cdot \sqrt{{im}^{10} \cdot \color{blue}{6.944444444444444 \cdot 10^{-5}}} \]
    10. Applied egg-rr71.0%

      \[\leadsto re \cdot \color{blue}{\sqrt{{im}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}} \]

    if -8.2e18 < im < 8.2000000000000007e41

    1. Initial program 36.7%

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

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

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

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

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

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

    if 8.2000000000000007e41 < 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 98.0%

      \[\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. associate-*r*98.0%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg98.0%

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 + \color{blue}{\left({im}^{5} \cdot -0.008333333333333333 + \left(-im\right)\right)}\right) \]
      13. sub-neg98.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.2 \cdot 10^{+18}:\\ \;\;\;\;re \cdot \sqrt{{im}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+41}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 7: 81.0% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8 \cdot 10^{+51} \lor \neg \left(im \leq 8.2 \cdot 10^{+41}\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -4.7999999999999997e51 or 8.2000000000000007e41 < 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.3%

      \[\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. associate-*r*97.3%

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

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

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

        \[\leadsto \sin re \cdot \left(-0.16666666666666666 \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)} \]
      5. mul-1-neg97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.7999999999999997e51 < im < 8.2000000000000007e41

    1. Initial program 38.4%

      \[\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}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg87.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.8 \cdot 10^{+51} \lor \neg \left(im \leq 8.2 \cdot 10^{+41}\right):\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \end{array} \]

Alternative 8: 56.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+53}:\\ \;\;\;\;-im \cdot re\\ \mathbf{elif}\;im \leq 1.85 \cdot 10^{+161}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;im \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -5.5e+53)
   (- (* im re))
   (if (<= im 1.85e+161) (* (- im) (sin re)) (* im re))))
double code(double re, double im) {
	double tmp;
	if (im <= -5.5e+53) {
		tmp = -(im * re);
	} else if (im <= 1.85e+161) {
		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.5d+53)) then
        tmp = -(im * re)
    else if (im <= 1.85d+161) 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.5e+53) {
		tmp = -(im * re);
	} else if (im <= 1.85e+161) {
		tmp = -im * Math.sin(re);
	} else {
		tmp = im * re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -5.5e+53:
		tmp = -(im * re)
	elif im <= 1.85e+161:
		tmp = -im * math.sin(re)
	else:
		tmp = im * re
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -5.5e+53)
		tmp = Float64(-Float64(im * re));
	elseif (im <= 1.85e+161)
		tmp = Float64(Float64(-im) * sin(re));
	else
		tmp = Float64(im * re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -5.5e+53)
		tmp = -(im * re);
	elseif (im <= 1.85e+161)
		tmp = -im * sin(re);
	else
		tmp = im * re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -5.5e+53], (-N[(im * re), $MachinePrecision]), If[LessEqual[im, 1.85e+161], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(im * re), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    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-lft-neg-in4.9%

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

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

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

    if -5.49999999999999975e53 < im < 1.8499999999999999e161

    1. Initial program 44.9%

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

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

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

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

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

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

    if 1.8499999999999999e161 < 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.8%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{0.16666666666666666 \cdot \left({re}^{3} \cdot im\right) + -1 \cdot \left(re \cdot im\right)}\right)} - 1 \]
      4. fma-def11.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, {re}^{3} \cdot im, -1 \cdot \left(re \cdot im\right)\right)}\right)} - 1 \]
      5. *-commutative11.2%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, \color{blue}{im \cdot {re}^{3}}, -1 \cdot \left(re \cdot im\right)\right)\right)} - 1 \]
      6. add-sqr-sqrt0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{-1 \cdot \left(re \cdot im\right)} \cdot \sqrt{-1 \cdot \left(re \cdot im\right)}}\right)\right)} - 1 \]
      7. sqrt-unprod35.0%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{\left(-1 \cdot \left(re \cdot im\right)\right) \cdot \left(-1 \cdot \left(re \cdot im\right)\right)}}\right)\right)} - 1 \]
      8. mul-1-neg35.0%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\color{blue}{\left(-re \cdot im\right)} \cdot \left(-1 \cdot \left(re \cdot im\right)\right)}\right)\right)} - 1 \]
      9. mul-1-neg35.0%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-re \cdot im\right)}}\right)\right)} - 1 \]
      10. sqr-neg35.0%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}}\right)\right)} - 1 \]
      11. sqrt-unprod24.3%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}}\right)\right)} - 1 \]
      12. add-sqr-sqrt24.3%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{re \cdot im}\right)\right)} - 1 \]
    7. Applied egg-rr24.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def24.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)\right)\right)} \]
      2. expm1-log1p41.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)} \]
      3. fma-udef41.5%

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left({re}^{3} \cdot 0.16666666666666666 + re\right)} \]
    10. Taylor expanded in re around 0 32.2%

      \[\leadsto \color{blue}{re \cdot im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.7%

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

Alternative 9: 33.5% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \cdot re \]

Alternative 10: 19.7% accurate, 102.7× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-1 \cdot \left(re \cdot im\right) + 0.16666666666666666 \cdot \left({re}^{3} \cdot im\right)\right)\right)} \]
    2. expm1-udef16.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-1 \cdot \left(re \cdot im\right) + 0.16666666666666666 \cdot \left({re}^{3} \cdot im\right)\right)} - 1} \]
    3. +-commutative16.8%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{0.16666666666666666 \cdot \left({re}^{3} \cdot im\right) + -1 \cdot \left(re \cdot im\right)}\right)} - 1 \]
    4. fma-def16.8%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, {re}^{3} \cdot im, -1 \cdot \left(re \cdot im\right)\right)}\right)} - 1 \]
    5. *-commutative16.8%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, \color{blue}{im \cdot {re}^{3}}, -1 \cdot \left(re \cdot im\right)\right)\right)} - 1 \]
    6. add-sqr-sqrt11.5%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{-1 \cdot \left(re \cdot im\right)} \cdot \sqrt{-1 \cdot \left(re \cdot im\right)}}\right)\right)} - 1 \]
    7. sqrt-unprod23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{\left(-1 \cdot \left(re \cdot im\right)\right) \cdot \left(-1 \cdot \left(re \cdot im\right)\right)}}\right)\right)} - 1 \]
    8. mul-1-neg23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\color{blue}{\left(-re \cdot im\right)} \cdot \left(-1 \cdot \left(re \cdot im\right)\right)}\right)\right)} - 1 \]
    9. mul-1-neg23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-re \cdot im\right)}}\right)\right)} - 1 \]
    10. sqr-neg23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}}\right)\right)} - 1 \]
    11. sqrt-unprod18.6%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}}\right)\right)} - 1 \]
    12. add-sqr-sqrt20.2%

      \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, \color{blue}{re \cdot im}\right)\right)} - 1 \]
  7. Applied egg-rr20.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)\right)} - 1} \]
  8. Step-by-step derivation
    1. expm1-def19.8%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)\right)\right)} \]
    2. expm1-log1p24.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.16666666666666666, im \cdot {re}^{3}, re \cdot im\right)} \]
    3. fma-udef24.8%

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

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

      \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot {re}^{3}\right) \cdot im} + re \cdot im \]
    6. distribute-rgt-out24.8%

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

      \[\leadsto im \cdot \left(\color{blue}{{re}^{3} \cdot 0.16666666666666666} + re\right) \]
  9. Simplified24.8%

    \[\leadsto \color{blue}{im \cdot \left({re}^{3} \cdot 0.16666666666666666 + re\right)} \]
  10. Taylor expanded in re around 0 19.7%

    \[\leadsto \color{blue}{re \cdot im} \]
  11. Final simplification19.7%

    \[\leadsto im \cdot re \]

Alternative 11: 2.7% accurate, 308.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto -3 \]

Alternative 12: 2.8% accurate, 308.0× speedup?

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

\\
-0.004629629629629629
\end{array}
Derivation
  1. Initial program 63.6%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-0.004629629629629629} \]
  6. Final simplification2.8%

    \[\leadsto -0.004629629629629629 \]

Alternative 13: 2.8% accurate, 308.0× speedup?

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

\\
-1.9380669946781487 \cdot 10^{-19}
\end{array}
Derivation
  1. Initial program 63.6%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1.9380669946781487 \cdot 10^{-19}} \]
  6. Final simplification2.9%

    \[\leadsto -1.9380669946781487 \cdot 10^{-19} \]

Alternative 14: 14.9% 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 63.6%

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

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

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

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

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

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

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

    \[\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 2023279 
(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))))