math.cos on complex, imaginary part

Percentage Accurate: 65.7% → 99.5%
Time: 10.7s
Alternatives: 12
Speedup: 2.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 65.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.4× speedup?

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

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 5.00000000000000024e-5

    1. Initial program 25.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-5}\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: 93.9% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq -2.3 \cdot 10^{+15} \lor \neg \left(im \leq 0.155\right) \land im \leq 3.5 \cdot 10^{+94}:\\
\;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -8.19999999999999977e97 < im < -2.3e15 or 0.154999999999999999 < im < 3.4999999999999997e94

    1. Initial program 100.0%

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

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

    if -2.3e15 < im < 0.154999999999999999 or 3.4999999999999997e94 < im

    1. Initial program 45.8%

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

      \[\leadsto \color{blue}{-0.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-neg97.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.2 \cdot 10^{+97}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -2.3 \cdot 10^{+15} \lor \neg \left(im \leq 0.155\right) \land im \leq 3.5 \cdot 10^{+94}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 3: 94.3% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 3.5 \cdot 10^{+94}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -8.19999999999999977e97 or 3.4999999999999997e94 < 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 95.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-neg95.8%

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

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

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

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

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

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

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

    if -8.19999999999999977e97 < im < -1.7e-5 or 2.70000000000000003e-4 < im < 3.4999999999999997e94

    1. Initial program 99.6%

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

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

    if -1.7e-5 < im < 2.70000000000000003e-4

    1. Initial program 24.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}{-1 \cdot \left(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg99.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.2 \cdot 10^{+97}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 0.00027:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 3.5 \cdot 10^{+94}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 4: 86.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -680:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 310000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.7 \cdot 10^{+102}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
   (if (<= im -7.2e+102)
     t_0
     (if (<= im -680.0)
       (log1p (expm1 (* im re)))
       (if (<= im 310000000000.0)
         (* im (- (sin re)))
         (if (<= im 5.7e+102)
           (log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re re))))
           t_0))))))
double code(double re, double im) {
	double t_0 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
	double tmp;
	if (im <= -7.2e+102) {
		tmp = t_0;
	} else if (im <= -680.0) {
		tmp = log1p(expm1((im * re)));
	} else if (im <= 310000000000.0) {
		tmp = im * -sin(re);
	} else if (im <= 5.7e+102) {
		tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
	double tmp;
	if (im <= -7.2e+102) {
		tmp = t_0;
	} else if (im <= -680.0) {
		tmp = Math.log1p(Math.expm1((im * re)));
	} else if (im <= 310000000000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 5.7e+102) {
		tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))
	tmp = 0
	if im <= -7.2e+102:
		tmp = t_0
	elif im <= -680.0:
		tmp = math.log1p(math.expm1((im * re)))
	elif im <= 310000000000.0:
		tmp = im * -math.sin(re)
	elif im <= 5.7e+102:
		tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0)))
	tmp = 0.0
	if (im <= -7.2e+102)
		tmp = t_0;
	elseif (im <= -680.0)
		tmp = log1p(expm1(Float64(im * re)));
	elseif (im <= 310000000000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 5.7e+102)
		tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * re))));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+102], t$95$0, If[LessEqual[im, -680.0], N[Log[1 + N[(Exp[N[(im * re), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 310000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.7e+102], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;im \leq 5.7 \cdot 10^{+102}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.2000000000000003e102 or 5.6999999999999999e102 < 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)} \]

    if -7.2000000000000003e102 < im < -680

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt1.4%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.7%

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

        \[\leadsto -im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)} \]
      6. add-sqr-sqrt0.8%

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.5%

        \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      8. log1p-udef0.8%

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.4%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod23.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg23.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod22.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt49.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr49.0%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 19.3%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(\color{blue}{re \cdot im}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt11.9%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \cdot \sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      2. sqrt-unprod23.0%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      3. neg-log23.0%

        \[\leadsto \sqrt{\color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)} \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      4. log1p-udef23.0%

        \[\leadsto \sqrt{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      5. log1p-expm1-u23.0%

        \[\leadsto \sqrt{\left(-\color{blue}{re \cdot im}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      6. neg-log23.0%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)}} \]
      7. log1p-udef23.0%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right)} \]
      8. log1p-expm1-u16.0%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{re \cdot im}\right)} \]
      9. sqr-neg16.0%

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

        \[\leadsto \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}} \]
      11. add-sqr-sqrt6.2%

        \[\leadsto \color{blue}{re \cdot im} \]
      12. log1p-expm1-u30.1%

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)} \]

    if -680 < im < 3.1e11

    1. Initial program 27.0%

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

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

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

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

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

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

    if 3.1e11 < im < 5.6999999999999999e102

    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. Step-by-step derivation
      1. distribute-rgt-neg-out3.3%

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt0.9%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.2%

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

        \[\leadsto -im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)} \]
      6. add-sqr-sqrt0.6%

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.3%

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

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.4%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.2%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod10.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg10.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod10.4%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt70.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr70.5%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 41.0%

      \[\leadsto \log \color{blue}{\left(-1 \cdot \left(re \cdot im\right) + \left(1 + -1 \cdot \left({re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)\right)\right)} \]
    8. Step-by-step derivation
      1. associate-+r+41.0%

        \[\leadsto \log \color{blue}{\left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) + -1 \cdot \left({re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)\right)} \]
      2. mul-1-neg41.0%

        \[\leadsto \log \left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) + \color{blue}{\left(-{re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)}\right) \]
      3. unsub-neg41.0%

        \[\leadsto \log \color{blue}{\left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)} \]
      4. +-commutative41.0%

        \[\leadsto \log \left(\color{blue}{\left(1 + -1 \cdot \left(re \cdot im\right)\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      5. mul-1-neg41.0%

        \[\leadsto \log \left(\left(1 + \color{blue}{\left(-re \cdot im\right)}\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      6. unsub-neg41.0%

        \[\leadsto \log \left(\color{blue}{\left(1 - re \cdot im\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      7. *-commutative41.0%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right) \cdot {re}^{2}}\right) \]
      8. distribute-rgt-out41.0%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left({im}^{2} \cdot \left(-1 + 0.5\right)\right)} \cdot {re}^{2}\right) \]
      9. unpow241.0%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(-1 + 0.5\right)\right) \cdot {re}^{2}\right) \]
      10. metadata-eval41.0%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot \color{blue}{-0.5}\right) \cdot {re}^{2}\right) \]
      11. unpow241.0%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    9. Simplified41.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -680:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 310000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.7 \cdot 10^{+102}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 5: 77.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{if}\;im \leq -5.2 \cdot 10^{+109}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -610:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1000000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
   (if (<= im -5.2e+109)
     t_0
     (if (<= im -610.0)
       (log1p (expm1 (* im re)))
       (if (<= im 1000000000000.0)
         (* im (- (sin re)))
         (if (<= im 6.6e+108)
           (log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re re))))
           t_0))))))
double code(double re, double im) {
	double t_0 = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -5.2e+109) {
		tmp = t_0;
	} else if (im <= -610.0) {
		tmp = log1p(expm1((im * re)));
	} else if (im <= 1000000000000.0) {
		tmp = im * -sin(re);
	} else if (im <= 6.6e+108) {
		tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -5.2e+109) {
		tmp = t_0;
	} else if (im <= -610.0) {
		tmp = Math.log1p(Math.expm1((im * re)));
	} else if (im <= 1000000000000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 6.6e+108) {
		tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	tmp = 0
	if im <= -5.2e+109:
		tmp = t_0
	elif im <= -610.0:
		tmp = math.log1p(math.expm1((im * re)))
	elif im <= 1000000000000.0:
		tmp = im * -math.sin(re)
	elif im <= 6.6e+108:
		tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	tmp = 0.0
	if (im <= -5.2e+109)
		tmp = t_0;
	elseif (im <= -610.0)
		tmp = log1p(expm1(Float64(im * re)));
	elseif (im <= 1000000000000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 6.6e+108)
		tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * re))));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.2e+109], t$95$0, If[LessEqual[im, -610.0], N[Log[1 + N[(Exp[N[(im * re), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1000000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 6.6e+108], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -610:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\

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

\mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -5.1999999999999997e109 or 6.60000000000000038e108 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -5.1999999999999997e109 < im < -610

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt1.4%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.8%

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

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

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.5%

        \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      8. log1p-udef0.8%

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.4%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod24.9%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg24.9%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod24.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt52.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr52.5%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 21.4%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(\color{blue}{re \cdot im}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt14.5%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \cdot \sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      2. sqrt-unprod24.9%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      3. neg-log24.9%

        \[\leadsto \sqrt{\color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)} \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      4. log1p-udef24.9%

        \[\leadsto \sqrt{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      5. log1p-expm1-u24.9%

        \[\leadsto \sqrt{\left(-\color{blue}{re \cdot im}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      6. neg-log24.9%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)}} \]
      7. log1p-udef24.9%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right)} \]
      8. log1p-expm1-u18.3%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{re \cdot im}\right)} \]
      9. sqr-neg18.3%

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}} \]
      10. sqrt-unprod4.2%

        \[\leadsto \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}} \]
      11. add-sqr-sqrt5.9%

        \[\leadsto \color{blue}{re \cdot im} \]
      12. log1p-expm1-u31.5%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)} \]
    9. Applied egg-rr31.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)} \]

    if -610 < im < 1e12

    1. Initial program 27.0%

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

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

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

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

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

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

    if 1e12 < im < 6.60000000000000038e108

    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. Step-by-step derivation
      1. distribute-rgt-neg-out3.3%

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt0.8%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.2%

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

        \[\leadsto -im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)} \]
      6. add-sqr-sqrt0.6%

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.3%

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

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.4%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.1%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod9.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg9.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod9.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt70.2%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr70.2%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 43.4%

      \[\leadsto \log \color{blue}{\left(-1 \cdot \left(re \cdot im\right) + \left(1 + -1 \cdot \left({re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)\right)\right)} \]
    8. Step-by-step derivation
      1. associate-+r+43.4%

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

        \[\leadsto \log \left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) + \color{blue}{\left(-{re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)}\right) \]
      3. unsub-neg43.4%

        \[\leadsto \log \color{blue}{\left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)} \]
      4. +-commutative43.4%

        \[\leadsto \log \left(\color{blue}{\left(1 + -1 \cdot \left(re \cdot im\right)\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      5. mul-1-neg43.4%

        \[\leadsto \log \left(\left(1 + \color{blue}{\left(-re \cdot im\right)}\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      6. unsub-neg43.4%

        \[\leadsto \log \left(\color{blue}{\left(1 - re \cdot im\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      7. *-commutative43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right) \cdot {re}^{2}}\right) \]
      8. distribute-rgt-out43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left({im}^{2} \cdot \left(-1 + 0.5\right)\right)} \cdot {re}^{2}\right) \]
      9. unpow243.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(-1 + 0.5\right)\right) \cdot {re}^{2}\right) \]
      10. metadata-eval43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot \color{blue}{-0.5}\right) \cdot {re}^{2}\right) \]
      11. unpow243.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    9. Simplified43.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.2 \cdot 10^{+109}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -610:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1000000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 6: 77.1% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{if}\;im \leq -1.6 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 9000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
   (if (<= im -1.6e-5)
     t_0
     (if (<= im 9000000000.0)
       (* im (- (sin re)))
       (if (<= im 6.6e+108)
         (log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re re))))
         t_0)))))
double code(double re, double im) {
	double t_0 = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -1.6e-5) {
		tmp = t_0;
	} else if (im <= 9000000000.0) {
		tmp = im * -sin(re);
	} else if (im <= 6.6e+108) {
		tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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 = re * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    if (im <= (-1.6d-5)) then
        tmp = t_0
    else if (im <= 9000000000.0d0) then
        tmp = im * -sin(re)
    else if (im <= 6.6d+108) then
        tmp = log(((1.0d0 - (im * re)) - (((im * im) * (-0.5d0)) * (re * re))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -1.6e-5) {
		tmp = t_0;
	} else if (im <= 9000000000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 6.6e+108) {
		tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	tmp = 0
	if im <= -1.6e-5:
		tmp = t_0
	elif im <= 9000000000.0:
		tmp = im * -math.sin(re)
	elif im <= 6.6e+108:
		tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	tmp = 0.0
	if (im <= -1.6e-5)
		tmp = t_0;
	elseif (im <= 9000000000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 6.6e+108)
		tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * re))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (((im ^ 3.0) * -0.16666666666666666) - im);
	tmp = 0.0;
	if (im <= -1.6e-5)
		tmp = t_0;
	elseif (im <= 9000000000.0)
		tmp = im * -sin(re);
	elseif (im <= 6.6e+108)
		tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.6e-5], t$95$0, If[LessEqual[im, 9000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 6.6e+108], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.59999999999999993e-5 or 6.60000000000000038e108 < im

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -1.59999999999999993e-5 < im < 9e9

    1. Initial program 26.5%

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

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

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

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

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

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

    if 9e9 < im < 6.60000000000000038e108

    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. Step-by-step derivation
      1. distribute-rgt-neg-out3.3%

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt0.8%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.2%

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

        \[\leadsto -im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)} \]
      6. add-sqr-sqrt0.6%

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.3%

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

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.4%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.1%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod9.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg9.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod9.5%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt70.2%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr70.2%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 43.4%

      \[\leadsto \log \color{blue}{\left(-1 \cdot \left(re \cdot im\right) + \left(1 + -1 \cdot \left({re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)\right)\right)} \]
    8. Step-by-step derivation
      1. associate-+r+43.4%

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

        \[\leadsto \log \left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) + \color{blue}{\left(-{re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)}\right) \]
      3. unsub-neg43.4%

        \[\leadsto \log \color{blue}{\left(\left(-1 \cdot \left(re \cdot im\right) + 1\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right)} \]
      4. +-commutative43.4%

        \[\leadsto \log \left(\color{blue}{\left(1 + -1 \cdot \left(re \cdot im\right)\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      5. mul-1-neg43.4%

        \[\leadsto \log \left(\left(1 + \color{blue}{\left(-re \cdot im\right)}\right) - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      6. unsub-neg43.4%

        \[\leadsto \log \left(\color{blue}{\left(1 - re \cdot im\right)} - {re}^{2} \cdot \left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right)\right) \]
      7. *-commutative43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left(-1 \cdot {im}^{2} + 0.5 \cdot {im}^{2}\right) \cdot {re}^{2}}\right) \]
      8. distribute-rgt-out43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \color{blue}{\left({im}^{2} \cdot \left(-1 + 0.5\right)\right)} \cdot {re}^{2}\right) \]
      9. unpow243.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(-1 + 0.5\right)\right) \cdot {re}^{2}\right) \]
      10. metadata-eval43.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot \color{blue}{-0.5}\right) \cdot {re}^{2}\right) \]
      11. unpow243.4%

        \[\leadsto \log \left(\left(1 - re \cdot im\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    9. Simplified43.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.6 \cdot 10^{-5}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 9000000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\ \;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 7: 77.7% accurate, 2.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.7e-5 or 6.60000000000000038e108 < im

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -1.7e-5 < im < 5.1e8

    1. Initial program 25.9%

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

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

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

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

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

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

    if 5.1e8 < im < 6.60000000000000038e108

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 510000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\ \;\;\;\;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 8: 60.6% accurate, 2.7× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if -620 < im < 5.1e8

    1. Initial program 26.4%

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

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

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

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

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

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

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

Alternative 9: 60.1% accurate, 2.8× speedup?

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

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

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


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

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

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

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

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

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

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

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

    if -650 < im < 9e9

    1. Initial program 27.0%

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

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

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

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

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

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

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

Alternative 10: 56.7% accurate, 2.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

    if -9.79999999999999969e30 < im < 7.4e40

    1. Initial program 34.7%

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

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

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

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

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

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

    if 7.4e40 < 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.4%

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

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

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

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

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

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt1.7%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg1.9%

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

        \[\leadsto -im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)} \]
      6. add-sqr-sqrt0.5%

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u0.1%

        \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      8. log1p-udef0.2%

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log0.2%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt0.1%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod25.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg25.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod29.7%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt83.9%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
    6. Applied egg-rr83.9%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 54.4%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(\color{blue}{re \cdot im}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt33.0%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \cdot \sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      2. sqrt-unprod54.3%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      3. neg-log54.3%

        \[\leadsto \sqrt{\color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)} \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      4. log1p-udef54.3%

        \[\leadsto \sqrt{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      5. log1p-expm1-u54.3%

        \[\leadsto \sqrt{\left(-\color{blue}{re \cdot im}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      6. neg-log54.3%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)}} \]
      7. log1p-udef54.3%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right)} \]
      8. log1p-expm1-u38.6%

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

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}} \]
      10. sqrt-unprod9.3%

        \[\leadsto \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}} \]
      11. add-sqr-sqrt16.0%

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

        \[\leadsto \color{blue}{im \cdot re} \]
    9. Applied egg-rr16.0%

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

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

Alternative 11: 33.5% accurate, 50.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -2.8 \cdot 10^{+167}:\\ \;\;\;\;im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -2.8e+167) (* im re) (* im (- re))))
double code(double re, double im) {
	double tmp;
	if (re <= -2.8e+167) {
		tmp = im * 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 (re <= (-2.8d+167)) then
        tmp = im * re
    else
        tmp = im * -re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -2.8e+167) {
		tmp = im * re;
	} else {
		tmp = im * -re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -2.8e+167:
		tmp = im * re
	else:
		tmp = im * -re
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -2.8e+167)
		tmp = Float64(im * re);
	else
		tmp = Float64(im * Float64(-re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -2.8e+167)
		tmp = im * re;
	else
		tmp = im * -re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -2.8e+167], N[(im * re), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -2.7999999999999999e167

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im \cdot \sin re} \]
      2. add-sqr-sqrt34.7%

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

        \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
      4. sqr-neg36.0%

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

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

        \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
      7. log1p-expm1-u2.2%

        \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      8. log1p-udef3.0%

        \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
      9. neg-log3.0%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
      10. add-sqr-sqrt1.4%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
      11. sqrt-unprod35.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
      12. sqr-neg35.0%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
      13. sqrt-unprod33.6%

        \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
      14. add-sqr-sqrt50.1%

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

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
    7. Taylor expanded in re around 0 17.1%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(\color{blue}{re \cdot im}\right)}\right) \]
    8. Step-by-step derivation
      1. add-sqr-sqrt13.7%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \cdot \sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      2. sqrt-unprod32.1%

        \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
      3. neg-log32.1%

        \[\leadsto \sqrt{\color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)} \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      4. log1p-udef32.1%

        \[\leadsto \sqrt{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      5. log1p-expm1-u32.1%

        \[\leadsto \sqrt{\left(-\color{blue}{re \cdot im}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
      6. neg-log32.1%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)}} \]
      7. log1p-udef31.3%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right)} \]
      8. log1p-expm1-u31.5%

        \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{re \cdot im}\right)} \]
      9. sqr-neg31.5%

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}} \]
      10. sqrt-unprod13.4%

        \[\leadsto \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}} \]
      11. add-sqr-sqrt26.5%

        \[\leadsto \color{blue}{re \cdot im} \]
      12. *-commutative26.5%

        \[\leadsto \color{blue}{im \cdot re} \]
    9. Applied egg-rr26.5%

      \[\leadsto \color{blue}{im \cdot re} \]

    if -2.7999999999999999e167 < re

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 20.1% accurate, 102.7× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-im \cdot \sin re} \]
    2. add-sqr-sqrt27.1%

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

      \[\leadsto -im \cdot \color{blue}{\sqrt{\sin re \cdot \sin re}} \]
    4. sqr-neg30.5%

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

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

      \[\leadsto -im \cdot \color{blue}{\left(-\sin re\right)} \]
    7. log1p-expm1-u9.2%

      \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
    8. log1p-udef9.9%

      \[\leadsto -\color{blue}{\log \left(1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)} \]
    9. neg-log9.9%

      \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)}\right)} \]
    10. add-sqr-sqrt3.8%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{-\sin re} \cdot \sqrt{-\sin re}\right)}\right)}\right) \]
    11. sqrt-unprod25.8%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sqrt{\left(-\sin re\right) \cdot \left(-\sin re\right)}}\right)}\right) \]
    12. sqr-neg25.8%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sqrt{\color{blue}{\sin re \cdot \sin re}}\right)}\right) \]
    13. sqrt-unprod24.3%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\left(\sqrt{\sin re} \cdot \sqrt{\sin re}\right)}\right)}\right) \]
    14. add-sqr-sqrt51.3%

      \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \color{blue}{\sin re}\right)}\right) \]
  6. Applied egg-rr51.3%

    \[\leadsto \color{blue}{\log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot \sin re\right)}\right)} \]
  7. Taylor expanded in re around 0 35.8%

    \[\leadsto \log \left(\frac{1}{1 + \mathsf{expm1}\left(\color{blue}{re \cdot im}\right)}\right) \]
  8. Step-by-step derivation
    1. add-sqr-sqrt25.9%

      \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \cdot \sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
    2. sqrt-unprod35.0%

      \[\leadsto \color{blue}{\sqrt{\log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)}} \]
    3. neg-log35.0%

      \[\leadsto \sqrt{\color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)} \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
    4. log1p-udef35.0%

      \[\leadsto \sqrt{\left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
    5. log1p-expm1-u35.0%

      \[\leadsto \sqrt{\left(-\color{blue}{re \cdot im}\right) \cdot \log \left(\frac{1}{1 + \mathsf{expm1}\left(re \cdot im\right)}\right)} \]
    6. neg-log35.0%

      \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \color{blue}{\left(-\log \left(1 + \mathsf{expm1}\left(re \cdot im\right)\right)\right)}} \]
    7. log1p-udef35.4%

      \[\leadsto \sqrt{\left(-re \cdot im\right) \cdot \left(-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot im\right)\right)}\right)} \]
    8. log1p-expm1-u27.6%

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

      \[\leadsto \sqrt{\color{blue}{\left(re \cdot im\right) \cdot \left(re \cdot im\right)}} \]
    10. sqrt-unprod12.3%

      \[\leadsto \color{blue}{\sqrt{re \cdot im} \cdot \sqrt{re \cdot im}} \]
    11. add-sqr-sqrt15.9%

      \[\leadsto \color{blue}{re \cdot im} \]
    12. *-commutative15.9%

      \[\leadsto \color{blue}{im \cdot re} \]
  9. Applied egg-rr15.9%

    \[\leadsto \color{blue}{im \cdot re} \]
  10. Final simplification15.9%

    \[\leadsto im \cdot re \]

Developer target: 99.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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