math.cos on complex, imaginary part

Percentage Accurate: 66.2% → 99.2%
Time: 9.1s
Alternatives: 12
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 66.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.2% 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^{-10}\right):\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \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-10)))
     (* t_0 (* 0.5 (sin re)))
     (* (- 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-10)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = -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-10)) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = -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-10):
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = -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-10))
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(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-10)))
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = -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-10]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $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^{-10}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\

\mathbf{else}:\\
\;\;\;\;\left(-im\right) \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 1.00000000000000004e-10 < (-.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)) < 1.00000000000000004e-10

    1. Initial program 29.2%

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

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

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

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

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

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

Alternative 2: 95.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -8.5 \cdot 10^{+102}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -1.65 \lor \neg \left(im \leq 6600\right) \land im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -8.5e+102)
   (* -0.16666666666666666 (* (sin re) (pow im 3.0)))
   (if (or (<= im -1.65) (and (not (<= im 6600.0)) (<= im 3.3e+102)))
     (* 0.5 (* (- (exp (- im)) (exp im)) re))
     (* (sin re) (- (* -0.16666666666666666 (pow im 3.0)) im)))))
double code(double re, double im) {
	double tmp;
	if (im <= -8.5e+102) {
		tmp = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
	} else if ((im <= -1.65) || (!(im <= 6600.0) && (im <= 3.3e+102))) {
		tmp = 0.5 * ((exp(-im) - exp(im)) * re);
	} else {
		tmp = sin(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-8.5d+102)) then
        tmp = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
    else if ((im <= (-1.65d0)) .or. (.not. (im <= 6600.0d0)) .and. (im <= 3.3d+102)) then
        tmp = 0.5d0 * ((exp(-im) - exp(im)) * re)
    else
        tmp = sin(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -8.5e+102) {
		tmp = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
	} else if ((im <= -1.65) || (!(im <= 6600.0) && (im <= 3.3e+102))) {
		tmp = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
	} else {
		tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -8.5e+102:
		tmp = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))
	elif (im <= -1.65) or (not (im <= 6600.0) and (im <= 3.3e+102)):
		tmp = 0.5 * ((math.exp(-im) - math.exp(im)) * re)
	else:
		tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -8.5e+102)
		tmp = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0)));
	elseif ((im <= -1.65) || (!(im <= 6600.0) && (im <= 3.3e+102)))
		tmp = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re));
	else
		tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -8.5e+102)
		tmp = -0.16666666666666666 * (sin(re) * (im ^ 3.0));
	elseif ((im <= -1.65) || (~((im <= 6600.0)) && (im <= 3.3e+102)))
		tmp = 0.5 * ((exp(-im) - exp(im)) * re);
	else
		tmp = sin(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -8.5e+102], N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -1.65], And[N[Not[LessEqual[im, 6600.0]], $MachinePrecision], LessEqual[im, 3.3e+102]]], N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $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}
\mathbf{if}\;im \leq -8.5 \cdot 10^{+102}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\

\mathbf{elif}\;im \leq -1.65 \lor \neg \left(im \leq 6600\right) \land im \leq 3.3 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + -1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-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 \color{blue}{\left(\sin re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \sin re \cdot im \]
      4. associate-*l*100.0%

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

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

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

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

    if -8.4999999999999996e102 < im < -1.6499999999999999 or 6600 < im < 3.29999999999999999e102

    1. Initial program 100.0%

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

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

    if -1.6499999999999999 < im < 6600 or 3.29999999999999999e102 < im

    1. Initial program 46.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.5 \cdot 10^{+102}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -1.65 \lor \neg \left(im \leq 6600\right) \land im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]

Alternative 3: 88.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot \sqrt{re \cdot \left(re \cdot {im}^{6}\right)}\\ t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{if}\;im \leq -1.25 \cdot 10^{+101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -12000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 6600:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (sqrt (* re (* re (pow im 6.0))))))
        (t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
   (if (<= im -1.25e+101)
     t_1
     (if (<= im -12000.0)
       t_0
       (if (<= im 6600.0)
         (* (- im) (sin re))
         (if (<= im 3.3e+102) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = -0.16666666666666666 * sqrt((re * (re * pow(im, 6.0))));
	double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
	double tmp;
	if (im <= -1.25e+101) {
		tmp = t_1;
	} else if (im <= -12000.0) {
		tmp = t_0;
	} else if (im <= 6600.0) {
		tmp = -im * sin(re);
	} else if (im <= 3.3e+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 = (-0.16666666666666666d0) * sqrt((re * (re * (im ** 6.0d0))))
    t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
    if (im <= (-1.25d+101)) then
        tmp = t_1
    else if (im <= (-12000.0d0)) then
        tmp = t_0
    else if (im <= 6600.0d0) then
        tmp = -im * sin(re)
    else if (im <= 3.3d+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 = -0.16666666666666666 * Math.sqrt((re * (re * Math.pow(im, 6.0))));
	double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
	double tmp;
	if (im <= -1.25e+101) {
		tmp = t_1;
	} else if (im <= -12000.0) {
		tmp = t_0;
	} else if (im <= 6600.0) {
		tmp = -im * Math.sin(re);
	} else if (im <= 3.3e+102) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.16666666666666666 * math.sqrt((re * (re * math.pow(im, 6.0))))
	t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))
	tmp = 0
	if im <= -1.25e+101:
		tmp = t_1
	elif im <= -12000.0:
		tmp = t_0
	elif im <= 6600.0:
		tmp = -im * math.sin(re)
	elif im <= 3.3e+102:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(-0.16666666666666666 * sqrt(Float64(re * Float64(re * (im ^ 6.0)))))
	t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0)))
	tmp = 0.0
	if (im <= -1.25e+101)
		tmp = t_1;
	elseif (im <= -12000.0)
		tmp = t_0;
	elseif (im <= 6600.0)
		tmp = Float64(Float64(-im) * sin(re));
	elseif (im <= 3.3e+102)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.16666666666666666 * sqrt((re * (re * (im ^ 6.0))));
	t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0));
	tmp = 0.0;
	if (im <= -1.25e+101)
		tmp = t_1;
	elseif (im <= -12000.0)
		tmp = t_0;
	elseif (im <= 6600.0)
		tmp = -im * sin(re);
	elseif (im <= 3.3e+102)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[Sqrt[N[(re * N[(re * N[Power[im, 6.0], $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, -1.25e+101], t$95$1, If[LessEqual[im, -12000.0], t$95$0, If[LessEqual[im, 6600.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot \sqrt{re \cdot \left(re \cdot {im}^{6}\right)}\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -1.25 \cdot 10^{+101}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.24999999999999997e101 or 3.29999999999999999e102 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -1.24999999999999997e101 < im < -12000 or 6600 < im < 3.29999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.16666666666666666 \cdot \sqrt{\left({im}^{3} \cdot re\right) \cdot \color{blue}{\left({im}^{3} \cdot re\right)}} \]
      5. swap-sqr29.7%

        \[\leadsto -0.16666666666666666 \cdot \sqrt{\color{blue}{\left({im}^{3} \cdot {im}^{3}\right) \cdot \left(re \cdot re\right)}} \]
      6. pow-prod-up29.7%

        \[\leadsto -0.16666666666666666 \cdot \sqrt{\color{blue}{{im}^{\left(3 + 3\right)}} \cdot \left(re \cdot re\right)} \]
      7. metadata-eval29.7%

        \[\leadsto -0.16666666666666666 \cdot \sqrt{{im}^{\color{blue}{6}} \cdot \left(re \cdot re\right)} \]
    8. Applied egg-rr29.7%

      \[\leadsto -0.16666666666666666 \cdot \color{blue}{\sqrt{{im}^{6} \cdot \left(re \cdot re\right)}} \]
    9. Step-by-step derivation
      1. associate-*r*34.6%

        \[\leadsto -0.16666666666666666 \cdot \sqrt{\color{blue}{\left({im}^{6} \cdot re\right) \cdot re}} \]
      2. *-commutative34.6%

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

        \[\leadsto -0.16666666666666666 \cdot \sqrt{re \cdot \color{blue}{\left(re \cdot {im}^{6}\right)}} \]
    10. Simplified34.6%

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

    if -12000 < im < 6600

    1. Initial program 30.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.25 \cdot 10^{+101}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -12000:\\ \;\;\;\;-0.16666666666666666 \cdot \sqrt{re \cdot \left(re \cdot {im}^{6}\right)}\\ \mathbf{elif}\;im \leq 6600:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;-0.16666666666666666 \cdot \sqrt{re \cdot \left(re \cdot {im}^{6}\right)}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 4: 95.1% 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 -8.5 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1.65:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 6600:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;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 -8.5e+102)
     t_1
     (if (<= im -1.65)
       t_0
       (if (<= im 6600.0)
         (* (- im) (sin re))
         (if (<= im 3.3e+102) 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 <= -8.5e+102) {
		tmp = t_1;
	} else if (im <= -1.65) {
		tmp = t_0;
	} else if (im <= 6600.0) {
		tmp = -im * sin(re);
	} else if (im <= 3.3e+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 = 0.5d0 * ((exp(-im) - exp(im)) * re)
    t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
    if (im <= (-8.5d+102)) then
        tmp = t_1
    else if (im <= (-1.65d0)) then
        tmp = t_0
    else if (im <= 6600.0d0) then
        tmp = -im * sin(re)
    else if (im <= 3.3d+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 = 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 <= -8.5e+102) {
		tmp = t_1;
	} else if (im <= -1.65) {
		tmp = t_0;
	} else if (im <= 6600.0) {
		tmp = -im * Math.sin(re);
	} else if (im <= 3.3e+102) {
		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 <= -8.5e+102:
		tmp = t_1
	elif im <= -1.65:
		tmp = t_0
	elif im <= 6600.0:
		tmp = -im * math.sin(re)
	elif im <= 3.3e+102:
		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 <= -8.5e+102)
		tmp = t_1;
	elseif (im <= -1.65)
		tmp = t_0;
	elseif (im <= 6600.0)
		tmp = Float64(Float64(-im) * sin(re));
	elseif (im <= 3.3e+102)
		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 <= -8.5e+102)
		tmp = t_1;
	elseif (im <= -1.65)
		tmp = t_0;
	elseif (im <= 6600.0)
		tmp = -im * sin(re);
	elseif (im <= 3.3e+102)
		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, -8.5e+102], t$95$1, If[LessEqual[im, -1.65], t$95$0, If[LessEqual[im, 6600.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3e+102], 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 -8.5 \cdot 10^{+102}:\\
\;\;\;\;t_1\\

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

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + -1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg99.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 \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. distribute-lft-out--99.0%

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

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

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

    if -8.4999999999999996e102 < im < -1.6499999999999999 or 6600 < im < 3.29999999999999999e102

    1. Initial program 100.0%

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

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

    if -1.6499999999999999 < im < 6600

    1. Initial program 30.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.5 \cdot 10^{+102}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -1.65:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 6600:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;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: 84.8% accurate, 1.5× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -2.39999999999999991 < im < 330

    1. Initial program 29.7%

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

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

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

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

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

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

    if 330 < 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 im around 0 3.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{0.16666666666666666 \cdot \left({re}^{3} \cdot im\right) + -1 \cdot \left(re \cdot im\right)} \]
      2. mul-1-neg21.6%

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

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

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

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

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

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

Alternative 6: 76.9% accurate, 2.7× speedup?

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

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

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

\mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4e3 or 3.2500000000000001e114 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -4e3 < im < 580

    1. Initial program 29.7%

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

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

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

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

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

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

    if 580 < im < 3.2500000000000001e114

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4000:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq 580:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 7: 76.9% accurate, 2.7× speedup?

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

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

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

\mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.2e6

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -1.2e6 < im < 550

    1. Initial program 29.7%

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

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

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

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

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

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

    if 550 < im < 3.2500000000000001e114

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.2500000000000001e114 < im

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + -1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-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 \color{blue}{\left(\sin re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \sin re \cdot im \]
      4. associate-*l*100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1200000:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq 550:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]

Alternative 8: 76.8% accurate, 2.7× speedup?

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

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

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

\mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\
\;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.1e6 or 3.2500000000000001e114 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -1.1e6 < im < 580

    1. Initial program 29.7%

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

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

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

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

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

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

    if 580 < im < 3.2500000000000001e114

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1100000:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq 580:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+114}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 9: 76.9% accurate, 2.8× speedup?

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -4e7 < im < 1.1e7

    1. Initial program 30.3%

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

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

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

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

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

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

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

Alternative 10: 73.9% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -65000 \lor \neg \left(im \leq 27500\right):\\
\;\;\;\;im \cdot \left(re \cdot \left(-0.16666666666666666 \cdot \left(im \cdot im\right)\right) - re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-0.16666666666666666 \cdot re\right) \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + re \cdot \left(-im\right) \]
      8. associate-*r*50.4%

        \[\leadsto \color{blue}{\left(\left(-0.16666666666666666 \cdot re\right) \cdot \left(im \cdot im\right)\right) \cdot im} + re \cdot \left(-im\right) \]
      9. fma-def50.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(-0.16666666666666666 \cdot re\right) \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right)} \]
      10. *-commutative50.4%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot -0.16666666666666666\right)} \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right) \]
    7. Applied egg-rr50.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(re \cdot -0.16666666666666666\right) \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out50.4%

        \[\leadsto \mathsf{fma}\left(\left(re \cdot -0.16666666666666666\right) \cdot \left(im \cdot im\right), im, \color{blue}{-re \cdot im}\right) \]
      2. fma-neg50.4%

        \[\leadsto \color{blue}{\left(\left(re \cdot -0.16666666666666666\right) \cdot \left(im \cdot im\right)\right) \cdot im - re \cdot im} \]
      3. distribute-rgt-out--50.4%

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

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

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

    if -65000 < im < 27500

    1. Initial program 30.3%

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

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

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

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

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

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

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

Alternative 11: 50.6% accurate, 28.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right)} \]
    2. distribute-lft-in50.3%

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

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

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

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

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

      \[\leadsto \left(-0.16666666666666666 \cdot re\right) \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + re \cdot \left(-im\right) \]
    8. associate-*r*48.8%

      \[\leadsto \color{blue}{\left(\left(-0.16666666666666666 \cdot re\right) \cdot \left(im \cdot im\right)\right) \cdot im} + re \cdot \left(-im\right) \]
    9. fma-def48.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(-0.16666666666666666 \cdot re\right) \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right)} \]
    10. *-commutative48.8%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot -0.16666666666666666\right)} \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right) \]
  7. Applied egg-rr48.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(re \cdot -0.16666666666666666\right) \cdot \left(im \cdot im\right), im, re \cdot \left(-im\right)\right)} \]
  8. Step-by-step derivation
    1. distribute-rgt-neg-out48.8%

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

      \[\leadsto \color{blue}{\left(\left(re \cdot -0.16666666666666666\right) \cdot \left(im \cdot im\right)\right) \cdot im - re \cdot im} \]
    3. distribute-rgt-out--48.8%

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

      \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(-0.16666666666666666 \cdot \left(im \cdot im\right)\right)} - re\right) \]
  9. Simplified48.8%

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

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

Alternative 12: 33.1% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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