math.cos on complex, imaginary part

Percentage Accurate: 65.2% → 99.5%
Time: 9.2s
Alternatives: 15
Speedup: 2.7×

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 15 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.2% 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 10^{-6}\right):\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) - im \cdot \sin re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e-6)))
     (* t_0 (* 0.5 (sin re)))
     (- (* -0.16666666666666666 (* (sin re) (pow im 3.0))) (* im (sin re))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = (-0.16666666666666666 * (sin(re) * pow(im, 3.0))) - (im * sin(re));
	}
	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 <= 1e-6)) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = (-0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0))) - (im * Math.sin(re));
	}
	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 <= 1e-6):
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = (-0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))) - (im * math.sin(re))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6))
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) - Float64(im * sin(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 1e-6)))
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = (-0.16666666666666666 * (sin(re) * (im ^ 3.0))) - (im * sin(re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 33.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative33.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in33.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def33.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval33.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified33.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. 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)} \]
    5. 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 -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \sin re\right)} - \sin re \cdot im \]
      4. *-commutative99.8%

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

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

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

Alternative 2: 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 10^{-6}\right):\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - 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 1e-6)))
     (* t_0 (* 0.5 (sin re)))
     (* (sin re) (- (* -0.16666666666666666 (pow im 3.0)) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((-0.16666666666666666 * pow(im, 3.0)) - 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 <= 1e-6)) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - 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 <= 1e-6):
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - 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 <= 1e-6))
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - 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 <= 1e-6)))
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * ((-0.16666666666666666 * (im ^ 3.0)) - 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, 1e-6]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $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 10^{-6}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - 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 9.99999999999999955e-7 < (-.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 -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.99999999999999955e-7

    1. Initial program 33.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative33.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in33.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def33.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval33.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified33.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.8%

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

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

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

      \[\leadsto \sin re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - 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 10^{-6}\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]

Alternative 3: 94.7% accurate, 1.4× speedup?

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

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

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

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

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000064e91 < im < -0.340000000000000024 or 0.032000000000000001 < im < 5.60000000000000037e102

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

      \[\leadsto \color{blue}{-0.08333333333333333 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{3}\right) + 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)} \]
    3. Step-by-step derivation
      1. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.08333333333333333 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot {re}^{3}} + 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right) \]
      2. unpow30.0%

        \[\leadsto \left(-0.08333333333333333 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot re\right)} + 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right) \]
      3. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(\left(-0.08333333333333333 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \left(re \cdot re\right)\right) \cdot re} + 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right) \]
      4. associate-*r*0.0%

        \[\leadsto \left(\left(-0.08333333333333333 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \left(re \cdot re\right)\right) \cdot re + \color{blue}{\left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot re} \]
      5. distribute-rgt-out0.0%

        \[\leadsto \color{blue}{re \cdot \left(\left(-0.08333333333333333 \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \left(re \cdot re\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      6. *-commutative0.0%

        \[\leadsto re \cdot \left(\color{blue}{\left(\left(e^{-im} - e^{im}\right) \cdot -0.08333333333333333\right)} \cdot \left(re \cdot re\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)\right) \]
      7. associate-*l*0.0%

        \[\leadsto re \cdot \left(\color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.08333333333333333 \cdot \left(re \cdot re\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right)\right) \]
      8. *-commutative0.0%

        \[\leadsto re \cdot \left(\left(e^{-im} - e^{im}\right) \cdot \left(-0.08333333333333333 \cdot \left(re \cdot re\right)\right) + \color{blue}{\left(e^{-im} - e^{im}\right) \cdot 0.5}\right) \]
      9. distribute-lft-out81.6%

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

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

    if -0.340000000000000024 < im < 0.032000000000000001

    1. Initial program 33.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative33.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in33.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def33.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval33.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified33.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8 \cdot 10^{+91}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -0.34:\\ \;\;\;\;re \cdot \left(\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.08333333333333333 \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{elif}\;im \leq 0.032:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;re \cdot \left(\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.08333333333333333 \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 4: 94.7% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;im \leq 9.5 \cdot 10^{+101}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.50000000000000018e109 or 9.49999999999999947e101 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000018e109 < im < -1.7e8 or 14000 < im < 9.49999999999999947e101

    1. Initial program 100.0%

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

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

    if -1.7e8 < im < 14000

    1. Initial program 34.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative34.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in34.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out34.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in34.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval34.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval34.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def34.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval34.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified34.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+109}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -170000000:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 14000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+101}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 5: 95.0% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;im \leq 9.5 \cdot 10^{+101}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.50000000000000018e109 or 9.49999999999999947e101 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000018e109 < im < -1.7e8 or 14000 < im < 9.49999999999999947e101

    1. Initial program 100.0%

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

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

    if -1.7e8 < im < 14000

    1. Initial program 34.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative34.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in34.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out34.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in34.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval34.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval34.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def34.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval34.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval34.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified34.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+109}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -170000000:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 14000:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+101}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 6: 83.7% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5 < im < 2.5

    1. Initial program 33.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative33.4%

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

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

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in33.4%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in33.4%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval33.4%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def33.4%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval33.4%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval33.3%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified33.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.7%

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

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

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

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

Alternative 7: 76.4% accurate, 2.6× speedup?

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

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+272} \lor \neg \left(im \leq 2.05 \cdot 10^{+288}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.7999999999999998e50 or 1.9999999999999998e23 < im < 1.54999999999999986e272 or 2.0499999999999999e288 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 77.9%

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998e50 < im < 1.9999999999999998e23

    1. Initial program 40.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative40.1%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg40.1%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in40.1%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out40.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in40.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval40.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval40.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def40.1%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval40.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified40.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 89.9%

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

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

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

    if 1.54999999999999986e272 < im < 2.0499999999999999e288

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto -0.16666666666666666 \cdot \color{blue}{7625597484987} - im \cdot \sin re \]
    8. Taylor expanded in re around 0 81.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+50}:\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+23}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+272} \lor \neg \left(im \leq 2.05 \cdot 10^{+288}\right):\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;-1270932914164.5 - im \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \end{array} \]

Alternative 8: 76.6% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.1 \cdot 10^{-7}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot \left(re \cdot {im}^{3}\right) + -2 \cdot \left(im \cdot re\right)\right)\\

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+272} \lor \neg \left(im \leq 1.22 \cdot 10^{+288}\right):\\
\;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.1e-7

    1. Initial program 99.5%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left(re \cdot {im}^{3}\right) + -2 \cdot \left(re \cdot im\right)\right)} \]

    if -3.1e-7 < im < 5.6000000000000003e24

    1. Initial program 35.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative35.1%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg35.1%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in35.1%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out35.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in35.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval35.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval35.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def35.1%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval35.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg35.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/35.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval35.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified35.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 96.9%

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

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

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

    if 5.6000000000000003e24 < im < 1.54999999999999986e272 or 1.22000000000000011e288 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 72.3%

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

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

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

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

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

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

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

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

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

    if 1.54999999999999986e272 < im < 1.22000000000000011e288

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto -0.16666666666666666 \cdot \color{blue}{7625597484987} - im \cdot \sin re \]
    8. Taylor expanded in re around 0 81.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.1 \cdot 10^{-7}:\\ \;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot \left(re \cdot {im}^{3}\right) + -2 \cdot \left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+24}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+272} \lor \neg \left(im \leq 1.22 \cdot 10^{+288}\right):\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;-1270932914164.5 - im \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \end{array} \]

Alternative 9: 77.1% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.8 \cdot 10^{+50} \lor \neg \left(im \leq 1.5 \cdot 10^{+25}\right):\\
\;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.7999999999999998e50 or 1.50000000000000003e25 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 78.9%

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998e50 < im < 1.50000000000000003e25

    1. Initial program 40.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative40.1%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg40.1%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in40.1%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out40.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in40.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval40.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval40.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def40.1%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval40.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval40.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified40.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 89.9%

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

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

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

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

Alternative 10: 58.3% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot {re}^{3}\\
\mathbf{if}\;im \leq -1.95 \cdot 10^{+34}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 5.5 \cdot 10^{+288}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.9500000000000001e34 or 680 < im < 5.5e288

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg100.0%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def100.0%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Applied egg-rr1.8%

      \[\leadsto \sin re \cdot \color{blue}{-3} \]
    5. Taylor expanded in re around 0 21.1%

      \[\leadsto \color{blue}{-3 \cdot re + 0.5 \cdot {re}^{3}} \]
    6. Taylor expanded in re around inf 21.0%

      \[\leadsto \color{blue}{0.5 \cdot {re}^{3}} \]
    7. Step-by-step derivation
      1. *-commutative21.0%

        \[\leadsto \color{blue}{{re}^{3} \cdot 0.5} \]
    8. Simplified21.0%

      \[\leadsto \color{blue}{{re}^{3} \cdot 0.5} \]

    if -1.9500000000000001e34 < im < 680

    1. Initial program 35.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative35.8%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg35.8%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in35.8%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out35.8%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in35.8%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval35.8%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval35.8%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def35.8%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval35.8%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg35.7%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/35.7%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval35.7%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified35.7%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 96.2%

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

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

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

    if 5.5e288 < im

    1. Initial program 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.95 \cdot 10^{+34}:\\ \;\;\;\;0.5 \cdot {re}^{3}\\ \mathbf{elif}\;im \leq 680:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.5 \cdot 10^{+288}:\\ \;\;\;\;0.5 \cdot {re}^{3}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(-2 \cdot \left(im \cdot re\right)\right)\\ \end{array} \]

Alternative 11: 56.3% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.5 \cdot 10^{+51} \lor \neg \left(im \leq 4.6 \cdot 10^{+222}\right):\\
\;\;\;\;0.5 \cdot \left(-2 \cdot \left(im \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.5e51 or 4.60000000000000021e222 < im

    1. Initial program 100.0%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(-2 \cdot \left(re \cdot im\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutative23.4%

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

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

    if -6.5e51 < im < 4.60000000000000021e222

    1. Initial program 53.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative53.1%

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

        \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      3. sub-neg53.1%

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

        \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      5. distribute-rgt-in53.1%

        \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      6. distribute-lft-neg-out53.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      7. distribute-rgt-neg-in53.1%

        \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      8. metadata-eval53.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      9. metadata-eval53.1%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      10. fma-def53.1%

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      11. metadata-eval53.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      12. exp-neg53.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      13. associate-*l/53.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      14. metadata-eval53.1%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified53.1%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 71.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.5 \cdot 10^{+51} \lor \neg \left(im \leq 4.6 \cdot 10^{+222}\right):\\ \;\;\;\;0.5 \cdot \left(-2 \cdot \left(im \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 12: 33.5% accurate, 44.0× speedup?

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

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

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

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

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

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

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

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

Alternative 13: 3.2% accurate, 102.7× speedup?

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

\\
re \cdot -3
\end{array}
Derivation
  1. Initial program 65.4%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. *-commutative65.4%

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

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

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

      \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
    5. distribute-rgt-in65.4%

      \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    6. distribute-lft-neg-out65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
    7. distribute-rgt-neg-in65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
    8. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
    9. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
    10. fma-def65.4%

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
    11. metadata-eval65.4%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
    12. exp-neg65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
    13. associate-*l/65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
    14. metadata-eval65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
  3. Simplified65.3%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
  4. Applied egg-rr3.3%

    \[\leadsto \sin re \cdot \color{blue}{-3} \]
  5. Taylor expanded in re around 0 3.1%

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

      \[\leadsto \color{blue}{re \cdot -3} \]
  7. Simplified3.1%

    \[\leadsto \color{blue}{re \cdot -3} \]
  8. Final simplification3.1%

    \[\leadsto re \cdot -3 \]

Alternative 14: 3.2% accurate, 102.7× speedup?

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

\\
re \cdot -0.001953125
\end{array}
Derivation
  1. Initial program 65.4%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. *-commutative65.4%

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

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

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

      \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
    5. distribute-rgt-in65.4%

      \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    6. distribute-lft-neg-out65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
    7. distribute-rgt-neg-in65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
    8. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
    9. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
    10. fma-def65.4%

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
    11. metadata-eval65.4%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
    12. exp-neg65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
    13. associate-*l/65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
    14. metadata-eval65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
  3. Simplified65.3%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
  4. Applied egg-rr3.4%

    \[\leadsto \sin re \cdot \color{blue}{-0.001953125} \]
  5. Taylor expanded in re around 0 3.2%

    \[\leadsto \color{blue}{re} \cdot -0.001953125 \]
  6. Final simplification3.2%

    \[\leadsto re \cdot -0.001953125 \]

Alternative 15: 14.8% accurate, 102.7× speedup?

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

\\
re \cdot 0
\end{array}
Derivation
  1. Initial program 65.4%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. *-commutative65.4%

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

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

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

      \[\leadsto \sin re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
    5. distribute-rgt-in65.4%

      \[\leadsto \sin re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    6. distribute-lft-neg-out65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
    7. distribute-rgt-neg-in65.4%

      \[\leadsto \sin re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
    8. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
    9. metadata-eval65.4%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
    10. fma-def65.4%

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
    11. metadata-eval65.4%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
    12. exp-neg65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
    13. associate-*l/65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
    14. metadata-eval65.3%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
  3. Simplified65.3%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
  4. Applied egg-rr16.7%

    \[\leadsto \sin re \cdot \color{blue}{0} \]
  5. Taylor expanded in re around 0 16.7%

    \[\leadsto \color{blue}{re} \cdot 0 \]
  6. Final simplification16.7%

    \[\leadsto re \cdot 0 \]

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 2023188 
(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))))