math.cos on complex, imaginary part

Percentage Accurate: 65.4% → 99.8%
Time: 8.0s
Alternatives: 15
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 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.4% 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.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

    if -0.20000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 5.0000000000000001e-4

    1. Initial program 23.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 87.6% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq -6.2 \cdot 10^{+18}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 3.05 \cdot 10^{+19}:\\
\;\;\;\;im \cdot \left(-\sin re\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 < -5.60000000000000037e102 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 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)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

    if -5.60000000000000037e102 < im < -6.2e18 or 3.05e19 < 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 4.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{0.027777777777777776 \cdot \left({im}^{6} \cdot \left(re \cdot re\right)\right)}} \]
    11. Step-by-step derivation
      1. metadata-eval48.7%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left({im}^{\color{blue}{\left(2 \cdot 3\right)}} \cdot \left(re \cdot re\right)\right)} \]
      2. pow-sqr48.7%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left(\color{blue}{\left({im}^{3} \cdot {im}^{3}\right)} \cdot \left(re \cdot re\right)\right)} \]
      3. associate-*r*48.7%

        \[\leadsto \sqrt{\color{blue}{\left(0.027777777777777776 \cdot \left({im}^{3} \cdot {im}^{3}\right)\right) \cdot \left(re \cdot re\right)}} \]
      4. *-commutative48.7%

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot re\right) \cdot \left(0.027777777777777776 \cdot \left({im}^{3} \cdot {im}^{3}\right)\right)}} \]
      5. pow-sqr48.7%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(0.027777777777777776 \cdot \color{blue}{{im}^{\left(2 \cdot 3\right)}}\right)} \]
      6. metadata-eval48.7%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(0.027777777777777776 \cdot {im}^{\color{blue}{6}}\right)} \]
    12. Simplified48.7%

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

    if -6.2e18 < im < 3.05e19

    1. Initial program 27.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+102}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -6.2 \cdot 10^{+18}:\\ \;\;\;\;\sqrt{\left(re \cdot re\right) \cdot \left(0.027777777777777776 \cdot {im}^{6}\right)}\\ \mathbf{elif}\;im \leq 3.05 \cdot 10^{+19}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\sqrt{\left(re \cdot re\right) \cdot \left(0.027777777777777776 \cdot {im}^{6}\right)}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 3: 95.2% 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -5.2 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0146:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.0048:\\ \;\;\;\;im \cdot \left(-\sin re\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 (* 0.5 (* (- (exp (- im)) (exp im)) re)))
        (t_1 (* (pow im 3.0) (* (sin re) -0.16666666666666666))))
   (if (<= im -5.2e+103)
     t_1
     (if (<= im -0.0146)
       t_0
       (if (<= im 0.0048)
         (* im (- (sin re)))
         (if (<= im 5.6e+102) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	double t_1 = pow(im, 3.0) * (sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -5.2e+103) {
		tmp = t_1;
	} else if (im <= -0.0146) {
		tmp = t_0;
	} else if (im <= 0.0048) {
		tmp = im * -sin(re);
	} 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 = 0.5d0 * ((exp(-im) - exp(im)) * re)
    t_1 = (im ** 3.0d0) * (sin(re) * (-0.16666666666666666d0))
    if (im <= (-5.2d+103)) then
        tmp = t_1
    else if (im <= (-0.0146d0)) then
        tmp = t_0
    else if (im <= 0.0048d0) then
        tmp = im * -sin(re)
    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 = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
	double t_1 = Math.pow(im, 3.0) * (Math.sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -5.2e+103) {
		tmp = t_1;
	} else if (im <= -0.0146) {
		tmp = t_0;
	} else if (im <= 0.0048) {
		tmp = im * -Math.sin(re);
	} else if (im <= 5.6e+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 = math.pow(im, 3.0) * (math.sin(re) * -0.16666666666666666)
	tmp = 0
	if im <= -5.2e+103:
		tmp = t_1
	elif im <= -0.0146:
		tmp = t_0
	elif im <= 0.0048:
		tmp = im * -math.sin(re)
	elif im <= 5.6e+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((im ^ 3.0) * Float64(sin(re) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -5.2e+103)
		tmp = t_1;
	elseif (im <= -0.0146)
		tmp = t_0;
	elseif (im <= 0.0048)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 5.6e+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 = (im ^ 3.0) * (sin(re) * -0.16666666666666666);
	tmp = 0.0;
	if (im <= -5.2e+103)
		tmp = t_1;
	elseif (im <= -0.0146)
		tmp = t_0;
	elseif (im <= 0.0048)
		tmp = im * -sin(re);
	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[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.2e+103], t$95$1, If[LessEqual[im, -0.0146], t$95$0, If[LessEqual[im, 0.0048], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.6e+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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -5.2 \cdot 10^{+103}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.0048:\\
\;\;\;\;im \cdot \left(-\sin re\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 < -5.2000000000000003e103 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 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)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

    if -5.2000000000000003e103 < im < -0.0146000000000000001 or 0.00479999999999999958 < 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 69.7%

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

    if -0.0146000000000000001 < im < 0.00479999999999999958

    1. Initial program 23.6%

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

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

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

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

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

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

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

Alternative 4: 95.4% 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -5.2 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.054:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.17:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 (* 0.5 (* (- (exp (- im)) (exp im)) re)))
        (t_1 (* (pow im 3.0) (* (sin re) -0.16666666666666666))))
   (if (<= im -5.2e+103)
     t_1
     (if (<= im -0.054)
       t_0
       (if (<= im 0.17)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 5.6e+102) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	double t_1 = pow(im, 3.0) * (sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -5.2e+103) {
		tmp = t_1;
	} else if (im <= -0.054) {
		tmp = t_0;
	} else if (im <= 0.17) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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 = 0.5d0 * ((exp(-im) - exp(im)) * re)
    t_1 = (im ** 3.0d0) * (sin(re) * (-0.16666666666666666d0))
    if (im <= (-5.2d+103)) then
        tmp = t_1
    else if (im <= (-0.054d0)) then
        tmp = t_0
    else if (im <= 0.17d0) then
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - 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 = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
	double t_1 = Math.pow(im, 3.0) * (Math.sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -5.2e+103) {
		tmp = t_1;
	} else if (im <= -0.054) {
		tmp = t_0;
	} else if (im <= 0.17) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 5.6e+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 = math.pow(im, 3.0) * (math.sin(re) * -0.16666666666666666)
	tmp = 0
	if im <= -5.2e+103:
		tmp = t_1
	elif im <= -0.054:
		tmp = t_0
	elif im <= 0.17:
		tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 5.6e+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((im ^ 3.0) * Float64(sin(re) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -5.2e+103)
		tmp = t_1;
	elseif (im <= -0.054)
		tmp = t_0;
	elseif (im <= 0.17)
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - 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 = 0.5 * ((exp(-im) - exp(im)) * re);
	t_1 = (im ^ 3.0) * (sin(re) * -0.16666666666666666);
	tmp = 0.0;
	if (im <= -5.2e+103)
		tmp = t_1;
	elseif (im <= -0.054)
		tmp = t_0;
	elseif (im <= 0.17)
		tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - 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[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.2e+103], t$95$1, If[LessEqual[im, -0.054], t$95$0, If[LessEqual[im, 0.17], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.6e+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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -5.2 \cdot 10^{+103}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.17:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 < -5.2000000000000003e103 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 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)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

    if -5.2000000000000003e103 < im < -0.0539999999999999994 or 0.170000000000000012 < 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 69.7%

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

    if -0.0539999999999999994 < im < 0.170000000000000012

    1. Initial program 23.6%

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

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

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

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

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

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

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

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

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

Alternative 5: 85.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -1.02 \cdot 10^{+104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -4 \cdot 10^{+51}:\\ \;\;\;\;\left|-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\right|\\ \mathbf{elif}\;im \leq 70000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+64}:\\ \;\;\;\;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 (* (pow im 3.0) (* (sin re) -0.16666666666666666))))
   (if (<= im -1.02e+104)
     t_0
     (if (<= im -4e+51)
       (fabs (* -0.16666666666666666 (* re (pow im 3.0))))
       (if (<= im 70000.0)
         (* im (- (sin re)))
         (if (<= im 1.5e+64)
           (* im (- (* 0.16666666666666666 (pow re 3.0)) re))
           t_0))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * (sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -1.02e+104) {
		tmp = t_0;
	} else if (im <= -4e+51) {
		tmp = fabs((-0.16666666666666666 * (re * pow(im, 3.0))));
	} else if (im <= 70000.0) {
		tmp = im * -sin(re);
	} else if (im <= 1.5e+64) {
		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 = (im ** 3.0d0) * (sin(re) * (-0.16666666666666666d0))
    if (im <= (-1.02d+104)) then
        tmp = t_0
    else if (im <= (-4d+51)) then
        tmp = abs(((-0.16666666666666666d0) * (re * (im ** 3.0d0))))
    else if (im <= 70000.0d0) then
        tmp = im * -sin(re)
    else if (im <= 1.5d+64) 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 = Math.pow(im, 3.0) * (Math.sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -1.02e+104) {
		tmp = t_0;
	} else if (im <= -4e+51) {
		tmp = Math.abs((-0.16666666666666666 * (re * Math.pow(im, 3.0))));
	} else if (im <= 70000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 1.5e+64) {
		tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * (math.sin(re) * -0.16666666666666666)
	tmp = 0
	if im <= -1.02e+104:
		tmp = t_0
	elif im <= -4e+51:
		tmp = math.fabs((-0.16666666666666666 * (re * math.pow(im, 3.0))))
	elif im <= 70000.0:
		tmp = im * -math.sin(re)
	elif im <= 1.5e+64:
		tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * Float64(sin(re) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -1.02e+104)
		tmp = t_0;
	elseif (im <= -4e+51)
		tmp = abs(Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))));
	elseif (im <= 70000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 1.5e+64)
		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 = (im ^ 3.0) * (sin(re) * -0.16666666666666666);
	tmp = 0.0;
	if (im <= -1.02e+104)
		tmp = t_0;
	elseif (im <= -4e+51)
		tmp = abs((-0.16666666666666666 * (re * (im ^ 3.0))));
	elseif (im <= 70000.0)
		tmp = im * -sin(re);
	elseif (im <= 1.5e+64)
		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[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.02e+104], t$95$0, If[LessEqual[im, -4e+51], N[Abs[N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 70000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.5e+64], 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -1.02 \cdot 10^{+104}:\\
\;\;\;\;t_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.02e104 or 1.5000000000000001e64 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e104 < im < -4e51

    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 20.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-neg20.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left(\left({im}^{3} \cdot re\right) \cdot \color{blue}{\left({im}^{3} \cdot re\right)}\right)} \]
      7. swap-sqr53.8%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \color{blue}{\left(\left({im}^{3} \cdot {im}^{3}\right) \cdot \left(re \cdot re\right)\right)}} \]
      8. pow-prod-up53.8%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left(\color{blue}{{im}^{\left(3 + 3\right)}} \cdot \left(re \cdot re\right)\right)} \]
      9. metadata-eval53.8%

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

      \[\leadsto \color{blue}{\sqrt{0.027777777777777776 \cdot \left({im}^{6} \cdot \left(re \cdot re\right)\right)}} \]
    11. Step-by-step derivation
      1. metadata-eval53.8%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left({im}^{\color{blue}{\left(2 \cdot 3\right)}} \cdot \left(re \cdot re\right)\right)} \]
      2. pow-sqr53.8%

        \[\leadsto \sqrt{0.027777777777777776 \cdot \left(\color{blue}{\left({im}^{3} \cdot {im}^{3}\right)} \cdot \left(re \cdot re\right)\right)} \]
      3. associate-*r*53.8%

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

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

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \color{blue}{\left(\left({im}^{3} \cdot {im}^{3}\right) \cdot 0.027777777777777776\right)}} \]
      6. metadata-eval53.8%

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

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

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

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

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

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

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

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

    if -4e51 < im < 7e4

    1. Initial program 30.6%

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

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

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

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

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

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

    if 7e4 < im < 1.5000000000000001e64

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.02 \cdot 10^{+104}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -4 \cdot 10^{+51}:\\ \;\;\;\;\left|-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\right|\\ \mathbf{elif}\;im \leq 70000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+64}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 6: 75.7% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;im \leq -4.3 \cdot 10^{+225}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;im \leq 3 \cdot 10^{+43}:\\
\;\;\;\;t_0\\

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


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

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

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

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

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

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

    if -5.2000000000000004e263 < im < -4.3000000000000001e225 or 59000 < im < 3.00000000000000017e43

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.3000000000000001e225 < im < -3.1000000000000001e47

    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 70.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-neg70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1000000000000001e47 < im < 59000

    1. Initial program 29.6%

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

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

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

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

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

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

    if 3.00000000000000017e43 < 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 79.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.2 \cdot 10^{+263}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -4.3 \cdot 10^{+225}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq -3.1 \cdot 10^{+47}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 59000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+43}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 7: 76.6% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3999999999999998e47 < im < 1.69999999999999987e-7

    1. Initial program 27.5%

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

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

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

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

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

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

    if 1.69999999999999987e-7 < im

    1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.4 \cdot 10^{+47}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 8: 76.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -4.6 \cdot 10^{+47} \lor \neg \left(im \leq 1.5 \cdot 10^{+40}\right):\\ \;\;\;\;-0.16666666666666666 \cdot \left(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 -4.6e+47) (not (<= im 1.5e+40)))
   (* -0.16666666666666666 (* re (pow im 3.0)))
   (* im (- (sin re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -4.6e+47) || !(im <= 1.5e+40)) {
		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 <= (-4.6d+47)) .or. (.not. (im <= 1.5d+40))) 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 <= -4.6e+47) || !(im <= 1.5e+40)) {
		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 <= -4.6e+47) or not (im <= 1.5e+40):
		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 <= -4.6e+47) || !(im <= 1.5e+40))
		tmp = Float64(-0.16666666666666666 * Float64(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 <= -4.6e+47) || ~((im <= 1.5e+40)))
		tmp = -0.16666666666666666 * (re * (im ^ 3.0));
	else
		tmp = im * -sin(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -4.6e+47], N[Not[LessEqual[im, 1.5e+40]], $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 -4.6 \cdot 10^{+47} \lor \neg \left(im \leq 1.5 \cdot 10^{+40}\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(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 < -4.5999999999999997e47 or 1.5000000000000001e40 < 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 79.1%

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

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

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

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

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

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

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

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

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

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

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

    if -4.5999999999999997e47 < im < 1.5000000000000001e40

    1. Initial program 33.0%

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

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

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

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

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

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

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

Alternative 9: 76.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.1 \cdot 10^{+47}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+38}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -3.1e+47)
   (* (pow im 3.0) (* re -0.16666666666666666))
   (if (<= im 2e+38)
     (* im (- (sin re)))
     (* -0.16666666666666666 (* re (pow im 3.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= -3.1e+47) {
		tmp = pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= 2e+38) {
		tmp = im * -sin(re);
	} else {
		tmp = -0.16666666666666666 * (re * pow(im, 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+47)) then
        tmp = (im ** 3.0d0) * (re * (-0.16666666666666666d0))
    else if (im <= 2d+38) then
        tmp = im * -sin(re)
    else
        tmp = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -3.1e+47) {
		tmp = Math.pow(im, 3.0) * (re * -0.16666666666666666);
	} else if (im <= 2e+38) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im, 3.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -3.1e+47:
		tmp = math.pow(im, 3.0) * (re * -0.16666666666666666)
	elif im <= 2e+38:
		tmp = im * -math.sin(re)
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im, 3.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -3.1e+47)
		tmp = Float64((im ^ 3.0) * Float64(re * -0.16666666666666666));
	elseif (im <= 2e+38)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -3.1e+47)
		tmp = (im ^ 3.0) * (re * -0.16666666666666666);
	elseif (im <= 2e+38)
		tmp = im * -sin(re);
	else
		tmp = -0.16666666666666666 * (re * (im ^ 3.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -3.1e+47], N[(N[Power[im, 3.0], $MachinePrecision] * N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2e+38], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1000000000000001e47 < im < 1.99999999999999995e38

    1. Initial program 33.0%

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

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

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

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

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

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

    if 1.99999999999999995e38 < 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 79.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.1 \cdot 10^{+47}:\\ \;\;\;\;{im}^{3} \cdot \left(re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+38}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 10: 54.3% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 51.7%

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

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

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

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

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

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

    if 4.8000000000000003e41 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 32.8% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 2.7% accurate, 308.0× speedup?

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

\\
-1.5
\end{array}
Derivation
  1. Initial program 61.5%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{-3} \]
  4. Final simplification2.8%

    \[\leadsto -1.5 \]

Alternative 13: 2.7% accurate, 308.0× speedup?

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

\\
-0.0023148148148148147
\end{array}
Derivation
  1. Initial program 61.5%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{-0.004629629629629629} \]
  4. Final simplification2.9%

    \[\leadsto -0.0023148148148148147 \]

Alternative 14: 2.8% accurate, 308.0× speedup?

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

\\
-4.96145150637606 \cdot 10^{-8}
\end{array}
Derivation
  1. Initial program 61.5%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{-9.92290301275212 \cdot 10^{-8}} \]
  4. Final simplification2.9%

    \[\leadsto -4.96145150637606 \cdot 10^{-8} \]

Alternative 15: 14.9% accurate, 308.0× speedup?

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{0} \]
  4. Final simplification10.9%

    \[\leadsto 0 \]

Developer target: 99.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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