math.cos on complex, imaginary part

Percentage Accurate: 66.2% → 99.3%
Time: 13.1s
Alternatives: 16
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 66.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := 0.5 \cdot \sin re\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+15} \lor \neg \left(t_0 \leq 0\right):\\ \;\;\;\;t_0 \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (sin re))))
   (if (or (<= t_0 -1e+15) (not (<= t_0 0.0)))
     (* t_0 t_1)
     (*
      t_1
      (+
       (* im -2.0)
       (+
        (* -0.3333333333333333 (pow im 3.0))
        (+
         (* -0.016666666666666666 (pow im 5.0))
         (* -0.0003968253968253968 (pow im 7.0)))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = 0.5 * sin(re);
	double tmp;
	if ((t_0 <= -1e+15) || !(t_0 <= 0.0)) {
		tmp = t_0 * t_1;
	} else {
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + ((-0.016666666666666666 * pow(im, 5.0)) + (-0.0003968253968253968 * pow(im, 7.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) :: t_1
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    t_1 = 0.5d0 * sin(re)
    if ((t_0 <= (-1d+15)) .or. (.not. (t_0 <= 0.0d0))) then
        tmp = t_0 * t_1
    else
        tmp = t_1 * ((im * (-2.0d0)) + (((-0.3333333333333333d0) * (im ** 3.0d0)) + (((-0.016666666666666666d0) * (im ** 5.0d0)) + ((-0.0003968253968253968d0) * (im ** 7.0d0)))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double t_1 = 0.5 * Math.sin(re);
	double tmp;
	if ((t_0 <= -1e+15) || !(t_0 <= 0.0)) {
		tmp = t_0 * t_1;
	} else {
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + ((-0.016666666666666666 * Math.pow(im, 5.0)) + (-0.0003968253968253968 * Math.pow(im, 7.0)))));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = 0.5 * math.sin(re)
	tmp = 0
	if (t_0 <= -1e+15) or not (t_0 <= 0.0):
		tmp = t_0 * t_1
	else:
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + ((-0.016666666666666666 * math.pow(im, 5.0)) + (-0.0003968253968253968 * math.pow(im, 7.0)))))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64(0.5 * sin(re))
	tmp = 0.0
	if ((t_0 <= -1e+15) || !(t_0 <= 0.0))
		tmp = Float64(t_0 * t_1);
	else
		tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(Float64(-0.016666666666666666 * (im ^ 5.0)) + Float64(-0.0003968253968253968 * (im ^ 7.0))))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = 0.5 * sin(re);
	tmp = 0.0;
	if ((t_0 <= -1e+15) || ~((t_0 <= 0.0)))
		tmp = t_0 * t_1;
	else
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + ((-0.016666666666666666 * (im ^ 5.0)) + (-0.0003968253968253968 * (im ^ 7.0)))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+15], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1e15 or 0.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.3%

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

    if -1e15 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0

    1. Initial program 26.2%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \cdot 10^{+15} \lor \neg \left(e^{-im} - e^{im} \leq 0\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\ \end{array} \]

Alternative 2: 99.2% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1e15 or 0.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.3%

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

    if -1e15 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0

    1. Initial program 26.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \cdot 10^{+15} \lor \neg \left(e^{-im} - e^{im} \leq 0\right):\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\ \end{array} \]

Alternative 3: 99.2% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.0200000000000000004 or 0.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.2%

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

    if -0.0200000000000000004 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0

    1. Initial program 25.7%

      \[\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(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-199.8%

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

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

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

Alternative 4: 96.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -1.5 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.9 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.0001984126984126984 (* (sin re) (pow im 7.0)))))
   (if (<= im -1.5e+48)
     t_0
     (if (<= im 1.9e+25)
       (log1p (expm1 (* im (- (sin re)))))
       (if (<= im 1.1e+44) (* (- (exp (- im)) (exp im)) (* 0.5 re)) t_0)))))
double code(double re, double im) {
	double t_0 = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
	double tmp;
	if (im <= -1.5e+48) {
		tmp = t_0;
	} else if (im <= 1.9e+25) {
		tmp = log1p(expm1((im * -sin(re))));
	} else if (im <= 1.1e+44) {
		tmp = (exp(-im) - exp(im)) * (0.5 * re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -1.5e+48) {
		tmp = t_0;
	} else if (im <= 1.9e+25) {
		tmp = Math.log1p(Math.expm1((im * -Math.sin(re))));
	} else if (im <= 1.1e+44) {
		tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -1.5e+48:
		tmp = t_0
	elif im <= 1.9e+25:
		tmp = math.log1p(math.expm1((im * -math.sin(re))))
	elif im <= 1.1e+44:
		tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -1.5e+48)
		tmp = t_0;
	elseif (im <= 1.9e+25)
		tmp = log1p(expm1(Float64(im * Float64(-sin(re)))));
	elseif (im <= 1.1e+44)
		tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.5e+48], t$95$0, If[LessEqual[im, 1.9e+25], N[Log[1 + N[(Exp[N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.5 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.9 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)\\

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.5e48 or 1.09999999999999998e44 < 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 \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 100.0%

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

    if -1.5e48 < im < 1.9e25

    1. Initial program 33.8%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-188.7%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Step-by-step derivation
      1. log1p-expm1-u_binary6494.7%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(-im\right) \cdot \sin re\right)\right)} \]
    6. Applied rewrite-once94.7%

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

    if 1.9e25 < im < 1.09999999999999998e44

    1. Initial program 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.5 \cdot 10^{+48}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq 1.9 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(-\sin re\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 5: 97.4% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -4.95 \cdot 10^{+33}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.94999999999999993e33 or 1.09999999999999998e44 < im

    1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 97.5%

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

    if -4.94999999999999993e33 < im < -0.0749999999999999972 or 0.0539999999999999994 < im < 1.09999999999999998e44

    1. Initial program 94.5%

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. *-commutative76.8%

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

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

    if -0.0749999999999999972 < im < 0.0539999999999999994

    1. Initial program 26.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.95 \cdot 10^{+33}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.075:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 0.054:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 6: 92.9% accurate, 1.5× speedup?

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

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


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

    1. Initial program 99.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 85.1%

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

    if -5.5 < im < 5.5999999999999996

    1. Initial program 26.2%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 92.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.1 \lor \neg \left(im \leq 4.2\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\

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


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

    1. Initial program 99.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 85.1%

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

    if -4.0999999999999996 < im < 4.20000000000000018

    1. Initial program 26.2%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-199.4%

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

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

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

Alternative 8: 87.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin re}{\frac{im}{im \cdot \left(-im\right)}}\\ t_1 := -0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -4.3 \cdot 10^{+137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.5 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+25}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (/ (sin re) (/ im (* im (- im)))))
        (t_1 (* -0.0001984126984126984 (* re (pow im 7.0)))))
   (if (<= im -4.3e+137)
     t_0
     (if (<= im -1.5e+48)
       t_1
       (if (<= im 1.16e+25)
         (* im (- (sin re)))
         (if (<= im 1.35e+154) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = sin(re) / (im / (im * -im));
	double t_1 = -0.0001984126984126984 * (re * pow(im, 7.0));
	double tmp;
	if (im <= -4.3e+137) {
		tmp = t_0;
	} else if (im <= -1.5e+48) {
		tmp = t_1;
	} else if (im <= 1.16e+25) {
		tmp = im * -sin(re);
	} else if (im <= 1.35e+154) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = sin(re) / (im / (im * -im))
    t_1 = (-0.0001984126984126984d0) * (re * (im ** 7.0d0))
    if (im <= (-4.3d+137)) then
        tmp = t_0
    else if (im <= (-1.5d+48)) then
        tmp = t_1
    else if (im <= 1.16d+25) then
        tmp = im * -sin(re)
    else if (im <= 1.35d+154) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.sin(re) / (im / (im * -im));
	double t_1 = -0.0001984126984126984 * (re * Math.pow(im, 7.0));
	double tmp;
	if (im <= -4.3e+137) {
		tmp = t_0;
	} else if (im <= -1.5e+48) {
		tmp = t_1;
	} else if (im <= 1.16e+25) {
		tmp = im * -Math.sin(re);
	} else if (im <= 1.35e+154) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.sin(re) / (im / (im * -im))
	t_1 = -0.0001984126984126984 * (re * math.pow(im, 7.0))
	tmp = 0
	if im <= -4.3e+137:
		tmp = t_0
	elif im <= -1.5e+48:
		tmp = t_1
	elif im <= 1.16e+25:
		tmp = im * -math.sin(re)
	elif im <= 1.35e+154:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(sin(re) / Float64(im / Float64(im * Float64(-im))))
	t_1 = Float64(-0.0001984126984126984 * Float64(re * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -4.3e+137)
		tmp = t_0;
	elseif (im <= -1.5e+48)
		tmp = t_1;
	elseif (im <= 1.16e+25)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 1.35e+154)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = sin(re) / (im / (im * -im));
	t_1 = -0.0001984126984126984 * (re * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -4.3e+137)
		tmp = t_0;
	elseif (im <= -1.5e+48)
		tmp = t_1;
	elseif (im <= 1.16e+25)
		tmp = im * -sin(re);
	elseif (im <= 1.35e+154)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] / N[(im / N[(im * (-im)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(re * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.3e+137], t$95$0, If[LessEqual[im, -1.5e+48], t$95$1, If[LessEqual[im, 1.16e+25], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sin re}{\frac{im}{im \cdot \left(-im\right)}}\\
t_1 := -0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -4.3 \cdot 10^{+137}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1.5 \cdot 10^{+48}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.29999999999999965e137 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-15.2%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity97.5%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/97.5%

        \[\leadsto \color{blue}{\frac{\sin re \cdot \left(0 \cdot 0 - im \cdot im\right)}{im}} \]
      6. metadata-eval97.5%

        \[\leadsto \frac{\sin re \cdot \left(\color{blue}{0} - im \cdot im\right)}{im} \]
      7. sub0-neg97.5%

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

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*97.5%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. distribute-rgt-neg-in97.5%

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

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

    if -4.29999999999999965e137 < im < -1.5e48 or 1.15999999999999992e25 < im < 1.35000000000000003e154

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 87.0%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. *-commutative87.0%

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

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

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

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

    if -1.5e48 < im < 1.15999999999999992e25

    1. Initial program 33.8%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-188.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.3 \cdot 10^{+137}:\\ \;\;\;\;\frac{\sin re}{\frac{im}{im \cdot \left(-im\right)}}\\ \mathbf{elif}\;im \leq -1.5 \cdot 10^{+48}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+25}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin re}{\frac{im}{im \cdot \left(-im\right)}}\\ \end{array} \]

Alternative 9: 81.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -1.3 \cdot 10^{+229}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -8.2 \cdot 10^{+166}:\\ \;\;\;\;\frac{\sin re}{im} \cdot \left(im \cdot \left(-im\right)\right)\\ \mathbf{elif}\;im \leq -1.5 \cdot 10^{+48} \lor \neg \left(im \leq 9.5 \cdot 10^{+26}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.0001984126984126984 (* re (pow im 7.0)))))
   (if (<= im -1.3e+229)
     t_0
     (if (<= im -8.2e+166)
       (* (/ (sin re) im) (* im (- im)))
       (if (or (<= im -1.5e+48) (not (<= im 9.5e+26)))
         t_0
         (* im (- (sin re))))))))
double code(double re, double im) {
	double t_0 = -0.0001984126984126984 * (re * pow(im, 7.0));
	double tmp;
	if (im <= -1.3e+229) {
		tmp = t_0;
	} else if (im <= -8.2e+166) {
		tmp = (sin(re) / im) * (im * -im);
	} else if ((im <= -1.5e+48) || !(im <= 9.5e+26)) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (-0.0001984126984126984d0) * (re * (im ** 7.0d0))
    if (im <= (-1.3d+229)) then
        tmp = t_0
    else if (im <= (-8.2d+166)) then
        tmp = (sin(re) / im) * (im * -im)
    else if ((im <= (-1.5d+48)) .or. (.not. (im <= 9.5d+26))) then
        tmp = t_0
    else
        tmp = im * -sin(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.0001984126984126984 * (re * Math.pow(im, 7.0));
	double tmp;
	if (im <= -1.3e+229) {
		tmp = t_0;
	} else if (im <= -8.2e+166) {
		tmp = (Math.sin(re) / im) * (im * -im);
	} else if ((im <= -1.5e+48) || !(im <= 9.5e+26)) {
		tmp = t_0;
	} else {
		tmp = im * -Math.sin(re);
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.0001984126984126984 * (re * math.pow(im, 7.0))
	tmp = 0
	if im <= -1.3e+229:
		tmp = t_0
	elif im <= -8.2e+166:
		tmp = (math.sin(re) / im) * (im * -im)
	elif (im <= -1.5e+48) or not (im <= 9.5e+26):
		tmp = t_0
	else:
		tmp = im * -math.sin(re)
	return tmp
function code(re, im)
	t_0 = Float64(-0.0001984126984126984 * Float64(re * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -1.3e+229)
		tmp = t_0;
	elseif (im <= -8.2e+166)
		tmp = Float64(Float64(sin(re) / im) * Float64(im * Float64(-im)));
	elseif ((im <= -1.5e+48) || !(im <= 9.5e+26))
		tmp = t_0;
	else
		tmp = Float64(im * Float64(-sin(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.0001984126984126984 * (re * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -1.3e+229)
		tmp = t_0;
	elseif (im <= -8.2e+166)
		tmp = (sin(re) / im) * (im * -im);
	elseif ((im <= -1.5e+48) || ~((im <= 9.5e+26)))
		tmp = t_0;
	else
		tmp = im * -sin(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.0001984126984126984 * N[(re * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+229], t$95$0, If[LessEqual[im, -8.2e+166], N[(N[(N[Sin[re], $MachinePrecision] / im), $MachinePrecision] * N[(im * (-im)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -1.5e+48], N[Not[LessEqual[im, 9.5e+26]], $MachinePrecision]], t$95$0, N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+229}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq -1.5 \cdot 10^{+48} \lor \neg \left(im \leq 9.5 \cdot 10^{+26}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.3e229 or -8.2000000000000005e166 < im < -1.5e48 or 9.50000000000000054e26 < 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.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 95.0%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. *-commutative95.0%

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

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

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

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

    if -1.3e229 < im < -8.2000000000000005e166

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-15.4%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity100.0%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{\sin re \cdot \left(0 \cdot 0 - im \cdot im\right)}{im}} \]
      6. metadata-eval100.0%

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

        \[\leadsto \frac{\sin re \cdot \color{blue}{\left(-im \cdot im\right)}}{im} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. associate-/r/100.0%

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

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

    if -1.5e48 < im < 9.50000000000000054e26

    1. Initial program 33.8%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-188.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+229}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -8.2 \cdot 10^{+166}:\\ \;\;\;\;\frac{\sin re}{im} \cdot \left(im \cdot \left(-im\right)\right)\\ \mathbf{elif}\;im \leq -1.5 \cdot 10^{+48} \lor \neg \left(im \leq 9.5 \cdot 10^{+26}\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 10: 81.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.5 \cdot 10^{+48} \lor \neg \left(im \leq 1.55 \cdot 10^{+26}\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.5e48 or 1.55e26 < 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.7%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    3. Taylor expanded in im around inf 95.7%

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. *-commutative95.7%

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

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

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

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

    if -1.5e48 < im < 1.55e26

    1. Initial program 33.8%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-188.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.5 \cdot 10^{+48} \lor \neg \left(im \leq 1.55 \cdot 10^{+26}\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 11: 60.1% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.6 \cdot 10^{+103} \lor \neg \left(im \leq 4.2 \cdot 10^{+32}\right):\\
\;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.59999999999999996e103 or 4.2000000000000001e32 < 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.7%

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-14.7%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity71.8%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/71.8%

        \[\leadsto \color{blue}{\frac{\sin re \cdot \left(0 \cdot 0 - im \cdot im\right)}{im}} \]
      6. metadata-eval71.8%

        \[\leadsto \frac{\sin re \cdot \left(\color{blue}{0} - im \cdot im\right)}{im} \]
      7. sub0-neg71.8%

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

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*71.8%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. associate-/r/43.6%

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

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

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

    if -1.59999999999999996e103 < im < 4.2000000000000001e32

    1. Initial program 37.7%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-183.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.6 \cdot 10^{+103} \lor \neg \left(im \leq 4.2 \cdot 10^{+32}\right):\\ \;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 12: 37.2% accurate, 21.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+103} \lor \neg \left(im \leq 2.6 \cdot 10^{-110}\right):\\ \;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-im}{re \cdot 0.16666666666666666 + \frac{1}{re}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -1.3e+103) (not (<= im 2.6e-110)))
   (* (* im (- im)) (/ re im))
   (/ (- im) (+ (* re 0.16666666666666666) (/ 1.0 re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -1.3e+103) || !(im <= 2.6e-110)) {
		tmp = (im * -im) * (re / im);
	} else {
		tmp = -im / ((re * 0.16666666666666666) + (1.0 / re));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-1.3d+103)) .or. (.not. (im <= 2.6d-110))) then
        tmp = (im * -im) * (re / im)
    else
        tmp = -im / ((re * 0.16666666666666666d0) + (1.0d0 / re))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -1.3e+103) || !(im <= 2.6e-110)) {
		tmp = (im * -im) * (re / im);
	} else {
		tmp = -im / ((re * 0.16666666666666666) + (1.0 / re));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -1.3e+103) or not (im <= 2.6e-110):
		tmp = (im * -im) * (re / im)
	else:
		tmp = -im / ((re * 0.16666666666666666) + (1.0 / re))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -1.3e+103) || !(im <= 2.6e-110))
		tmp = Float64(Float64(im * Float64(-im)) * Float64(re / im));
	else
		tmp = Float64(Float64(-im) / Float64(Float64(re * 0.16666666666666666) + Float64(1.0 / re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -1.3e+103) || ~((im <= 2.6e-110)))
		tmp = (im * -im) * (re / im);
	else
		tmp = -im / ((re * 0.16666666666666666) + (1.0 / re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -1.3e+103], N[Not[LessEqual[im, 2.6e-110]], $MachinePrecision]], N[(N[(im * (-im)), $MachinePrecision] * N[(re / im), $MachinePrecision]), $MachinePrecision], N[((-im) / N[(N[(re * 0.16666666666666666), $MachinePrecision] + N[(1.0 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.3 \cdot 10^{+103} \lor \neg \left(im \leq 2.6 \cdot 10^{-110}\right):\\
\;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\

\mathbf{else}:\\
\;\;\;\;\frac{-im}{re \cdot 0.16666666666666666 + \frac{1}{re}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.3000000000000001e103 or 2.5999999999999999e-110 < im

    1. Initial program 89.9%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-117.4%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity73.6%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/71.7%

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

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

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

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*73.6%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. associate-/r/50.0%

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

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

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

    if -1.3000000000000001e103 < im < 2.5999999999999999e-110

    1. Initial program 37.6%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-183.8%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity48.8%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/45.5%

        \[\leadsto \color{blue}{\frac{\sin re \cdot \left(0 \cdot 0 - im \cdot im\right)}{im}} \]
      6. metadata-eval45.5%

        \[\leadsto \frac{\sin re \cdot \left(\color{blue}{0} - im \cdot im\right)}{im} \]
      7. sub0-neg45.5%

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

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*48.7%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. associate-/r/48.7%

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

      \[\leadsto \color{blue}{\frac{\sin re}{im} \cdot \left(-im \cdot im\right)} \]
    9. Step-by-step derivation
      1. *-commutative48.7%

        \[\leadsto \color{blue}{\left(-im \cdot im\right) \cdot \frac{\sin re}{im}} \]
      2. clear-num48.7%

        \[\leadsto \left(-im \cdot im\right) \cdot \color{blue}{\frac{1}{\frac{im}{\sin re}}} \]
      3. un-div-inv48.7%

        \[\leadsto \color{blue}{\frac{-im \cdot im}{\frac{im}{\sin re}}} \]
      4. distribute-lft-neg-in48.7%

        \[\leadsto \frac{\color{blue}{\left(-im\right) \cdot im}}{\frac{im}{\sin re}} \]
      5. associate-/l*83.6%

        \[\leadsto \color{blue}{\frac{-im}{\frac{\frac{im}{\sin re}}{im}}} \]
    10. Applied egg-rr83.6%

      \[\leadsto \color{blue}{\frac{-im}{\frac{\frac{im}{\sin re}}{im}}} \]
    11. Taylor expanded in re around 0 40.3%

      \[\leadsto \frac{-im}{\color{blue}{0.16666666666666666 \cdot re + \frac{1}{re}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+103} \lor \neg \left(im \leq 2.6 \cdot 10^{-110}\right):\\ \;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-im}{re \cdot 0.16666666666666666 + \frac{1}{re}}\\ \end{array} \]

Alternative 13: 36.6% accurate, 25.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+170} \lor \neg \left(im \leq 1.05 \cdot 10^{+155}\right):\\ \;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -6e+170) (not (<= im 1.05e+155)))
   (* (* im (- im)) (/ re im))
   (* (- im) re)))
double code(double re, double im) {
	double tmp;
	if ((im <= -6e+170) || !(im <= 1.05e+155)) {
		tmp = (im * -im) * (re / im);
	} 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 <= (-6d+170)) .or. (.not. (im <= 1.05d+155))) then
        tmp = (im * -im) * (re / im)
    else
        tmp = -im * re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -6e+170) || !(im <= 1.05e+155)) {
		tmp = (im * -im) * (re / im);
	} else {
		tmp = -im * re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -6e+170) or not (im <= 1.05e+155):
		tmp = (im * -im) * (re / im)
	else:
		tmp = -im * re
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -6e+170) || !(im <= 1.05e+155))
		tmp = Float64(Float64(im * Float64(-im)) * Float64(re / im));
	else
		tmp = Float64(Float64(-im) * re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -6e+170) || ~((im <= 1.05e+155)))
		tmp = (im * -im) * (re / im);
	else
		tmp = -im * re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -6e+170], N[Not[LessEqual[im, 1.05e+155]], $MachinePrecision]], N[(N[(im * (-im)), $MachinePrecision] * N[(re / im), $MachinePrecision]), $MachinePrecision], N[((-im) * re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6 \cdot 10^{+170} \lor \neg \left(im \leq 1.05 \cdot 10^{+155}\right):\\
\;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.99999999999999994e170 or 1.05e155 < im

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-15.4%

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. +-lft-identity100.0%

        \[\leadsto \sin re \cdot \frac{0 \cdot 0 - im \cdot im}{\color{blue}{im}} \]
      5. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{\sin re \cdot \left(0 \cdot 0 - im \cdot im\right)}{im}} \]
      6. metadata-eval100.0%

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

        \[\leadsto \frac{\sin re \cdot \color{blue}{\left(-im \cdot im\right)}}{im} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\sin re \cdot \left(-im \cdot im\right)}{im}} \]
    7. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{\sin re}{\frac{im}{-im \cdot im}}} \]
      2. associate-/r/60.3%

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

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

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

    if -5.99999999999999994e170 < im < 1.05e155

    1. Initial program 49.3%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
      2. neg-mul-168.7%

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot re} \]
      2. neg-mul-136.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6 \cdot 10^{+170} \lor \neg \left(im \leq 1.05 \cdot 10^{+155}\right):\\ \;\;\;\;\left(im \cdot \left(-im\right)\right) \cdot \frac{re}{im}\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \cdot re\\ \end{array} \]

Alternative 14: 32.8% accurate, 77.0× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \sin re} \]
    2. neg-mul-151.9%

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot re} \]
    2. neg-mul-129.7%

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

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

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

Alternative 15: 2.7% accurate, 308.0× speedup?

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

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

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Applied egg-rr2.7%

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

    \[\leadsto \color{blue}{-3} \]
  4. Final simplification2.7%

    \[\leadsto -3 \]

Alternative 16: 3.2% accurate, 308.0× speedup?

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

\\
re
\end{array}
Derivation
  1. Initial program 62.7%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Applied egg-rr3.2%

    \[\leadsto \color{blue}{\frac{-3}{\frac{-3}{\sin re}}} \]
  3. Step-by-step derivation
    1. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{-3}{-3} \cdot \sin re} \]
    2. metadata-eval3.2%

      \[\leadsto \color{blue}{1} \cdot \sin re \]
    3. *-lft-identity3.2%

      \[\leadsto \color{blue}{\sin re} \]
  4. Simplified3.2%

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

    \[\leadsto \color{blue}{re} \]
  6. Final simplification3.0%

    \[\leadsto re \]

Developer target: 99.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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