math.cos on complex, imaginary part

Percentage Accurate: 65.9% → 99.9%
Time: 2.9s
Alternatives: 6
Speedup: 1.5×

Specification

?
\[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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[(1/2 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)

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 6 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.9% accurate, 1.0× speedup?

\[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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[(1/2 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)

Alternative 1: 99.9% accurate, 1.5× speedup?

\[\sinh \left(-im\right) \cdot \sin re \]
(FPCore (re im)
  :precision binary64
  (* (sinh (- im)) (sin re)))
double code(double re, double im) {
	return sinh(-im) * sin(re);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sinh(-im) * sin(re)
end function
public static double code(double re, double im) {
	return Math.sinh(-im) * Math.sin(re);
}
def code(re, im):
	return math.sinh(-im) * math.sin(re)
function code(re, im)
	return Float64(sinh(Float64(-im)) * sin(re))
end
function tmp = code(re, im)
	tmp = sinh(-im) * sin(re);
end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
\sinh \left(-im\right) \cdot \sin re
Derivation
  1. Initial program 65.9%

    \[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot \sin re\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \]
    4. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\left(e^{-im} - e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    5. lift--.f64N/A

      \[\leadsto \left(\color{blue}{\left(e^{-im} - e^{im}\right)} \cdot \frac{1}{2}\right) \cdot \sin re \]
    6. sub-negate-revN/A

      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(e^{im} - e^{-im}\right)\right)\right)} \cdot \frac{1}{2}\right) \cdot \sin re \]
    7. distribute-lft-neg-outN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(e^{im} - e^{-im}\right) \cdot \frac{1}{2}\right)\right)} \cdot \sin re \]
    8. metadata-evalN/A

      \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{-im}\right) \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot \sin re \]
    9. mult-flipN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{e^{im} - e^{-im}}{2}}\right)\right) \cdot \sin re \]
    10. lift-exp.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{e^{im}} - e^{-im}}{2}\right)\right) \cdot \sin re \]
    11. lift-exp.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{e^{im} - \color{blue}{e^{-im}}}{2}\right)\right) \cdot \sin re \]
    12. lift-neg.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{e^{im} - e^{\color{blue}{\mathsf{neg}\left(im\right)}}}{2}\right)\right) \cdot \sin re \]
    13. sinh-defN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sinh im}\right)\right) \cdot \sin re \]
    14. sinh-negN/A

      \[\leadsto \color{blue}{\sinh \left(\mathsf{neg}\left(im\right)\right)} \cdot \sin re \]
    15. lift-neg.f64N/A

      \[\leadsto \sinh \color{blue}{\left(-im\right)} \cdot \sin re \]
    16. lower-*.f64N/A

      \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \sin re} \]
    17. lower-sinh.f6499.9%

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

    \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \sin re} \]
  4. Add Preprocessing

Alternative 2: 96.6% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := \sin \left(\left|re\right|\right)\\ t_2 := \left(\frac{1}{2} \cdot t\_1\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right)\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq \frac{-891101683129335}{4455508415646675018204269146191690746966043464109921807206242693261010905477224010259680479802120507596330380442963288389344438204468201170168614570041224793214838549179946240315306828365824}:\\ \;\;\;\;\left(-2 \cdot \sinh \left(\left|im\right|\right)\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\ \mathbf{elif}\;t\_2 \leq \frac{7378697629483821}{147573952589676412928}:\\ \;\;\;\;t\_1 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(\left|re\right| \cdot \left(\left(1 - \left|im\right| \cdot \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \frac{\frac{1}{6}}{\left|im\right|}\right)\right) \cdot \left|im\right|\right)\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im)))
       (t_1 (sin (fabs re)))
       (t_2 (* (* 1/2 t_1) (- (exp t_0) (exp (fabs im))))))
  (*
   (copysign 1 re)
   (*
    (copysign 1 im)
    (if (<=
         t_2
         -891101683129335/4455508415646675018204269146191690746966043464109921807206242693261010905477224010259680479802120507596330380442963288389344438204468201170168614570041224793214838549179946240315306828365824)
      (* (* -2 (sinh (fabs im))) (* (fabs re) 1/2))
      (if (<= t_2 7378697629483821/147573952589676412928)
        (* t_1 t_0)
        (*
         -1
         (*
          (fabs re)
          (*
           (-
            1
            (*
             (fabs im)
             (* (* (fabs re) (fabs re)) (/ 1/6 (fabs im)))))
           (fabs im))))))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double t_1 = sin(fabs(re));
	double t_2 = (0.5 * t_1) * (exp(t_0) - exp(fabs(im)));
	double tmp;
	if (t_2 <= -2e-175) {
		tmp = (-2.0 * sinh(fabs(im))) * (fabs(re) * 0.5);
	} else if (t_2 <= 5e-5) {
		tmp = t_1 * t_0;
	} else {
		tmp = -1.0 * (fabs(re) * ((1.0 - (fabs(im) * ((fabs(re) * fabs(re)) * (0.16666666666666666 / fabs(im))))) * fabs(im)));
	}
	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
public static double code(double re, double im) {
	double t_0 = -Math.abs(im);
	double t_1 = Math.sin(Math.abs(re));
	double t_2 = (0.5 * t_1) * (Math.exp(t_0) - Math.exp(Math.abs(im)));
	double tmp;
	if (t_2 <= -2e-175) {
		tmp = (-2.0 * Math.sinh(Math.abs(im))) * (Math.abs(re) * 0.5);
	} else if (t_2 <= 5e-5) {
		tmp = t_1 * t_0;
	} else {
		tmp = -1.0 * (Math.abs(re) * ((1.0 - (Math.abs(im) * ((Math.abs(re) * Math.abs(re)) * (0.16666666666666666 / Math.abs(im))))) * Math.abs(im)));
	}
	return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
}
def code(re, im):
	t_0 = -math.fabs(im)
	t_1 = math.sin(math.fabs(re))
	t_2 = (0.5 * t_1) * (math.exp(t_0) - math.exp(math.fabs(im)))
	tmp = 0
	if t_2 <= -2e-175:
		tmp = (-2.0 * math.sinh(math.fabs(im))) * (math.fabs(re) * 0.5)
	elif t_2 <= 5e-5:
		tmp = t_1 * t_0
	else:
		tmp = -1.0 * (math.fabs(re) * ((1.0 - (math.fabs(im) * ((math.fabs(re) * math.fabs(re)) * (0.16666666666666666 / math.fabs(im))))) * math.fabs(im)))
	return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
function code(re, im)
	t_0 = Float64(-abs(im))
	t_1 = sin(abs(re))
	t_2 = Float64(Float64(0.5 * t_1) * Float64(exp(t_0) - exp(abs(im))))
	tmp = 0.0
	if (t_2 <= -2e-175)
		tmp = Float64(Float64(-2.0 * sinh(abs(im))) * Float64(abs(re) * 0.5));
	elseif (t_2 <= 5e-5)
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(-1.0 * Float64(abs(re) * Float64(Float64(1.0 - Float64(abs(im) * Float64(Float64(abs(re) * abs(re)) * Float64(0.16666666666666666 / abs(im))))) * abs(im))));
	end
	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
end
function tmp_2 = code(re, im)
	t_0 = -abs(im);
	t_1 = sin(abs(re));
	t_2 = (0.5 * t_1) * (exp(t_0) - exp(abs(im)));
	tmp = 0.0;
	if (t_2 <= -2e-175)
		tmp = (-2.0 * sinh(abs(im))) * (abs(re) * 0.5);
	elseif (t_2 <= 5e-5)
		tmp = t_1 * t_0;
	else
		tmp = -1.0 * (abs(re) * ((1.0 - (abs(im) * ((abs(re) * abs(re)) * (0.16666666666666666 / abs(im))))) * abs(im)));
	end
	tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp);
end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(1/2 * t$95$1), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -891101683129335/4455508415646675018204269146191690746966043464109921807206242693261010905477224010259680479802120507596330380442963288389344438204468201170168614570041224793214838549179946240315306828365824], N[(N[(-2 * N[Sinh[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 7378697629483821/147573952589676412928], N[(t$95$1 * t$95$0), $MachinePrecision], N[(-1 * N[(N[Abs[re], $MachinePrecision] * N[(N[(1 - N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1/6 / N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := \sin \left(\left|re\right|\right)\\
t_2 := \left(\frac{1}{2} \cdot t\_1\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{-891101683129335}{4455508415646675018204269146191690746966043464109921807206242693261010905477224010259680479802120507596330380442963288389344438204468201170168614570041224793214838549179946240315306828365824}:\\
\;\;\;\;\left(-2 \cdot \sinh \left(\left|im\right|\right)\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\

\mathbf{elif}\;t\_2 \leq \frac{7378697629483821}{147573952589676412928}:\\
\;\;\;\;t\_1 \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\left|re\right| \cdot \left(\left(1 - \left|im\right| \cdot \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \frac{\frac{1}{6}}{\left|im\right|}\right)\right) \cdot \left|im\right|\right)\right)\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -2e-175

    1. Initial program 65.9%

      \[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      2. sub-negate-revN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\left(e^{im} - e^{-im}\right)\right)\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\mathsf{neg}\left(\left(e^{im} - \color{blue}{e^{-im}}\right)\right)\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\mathsf{neg}\left(\left(e^{im} - e^{\color{blue}{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
      5. exp-negN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\mathsf{neg}\left(\left(e^{im} - \color{blue}{\frac{1}{e^{im}}}\right)\right)\right) \]
      6. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\mathsf{neg}\left(\left(e^{im} - \frac{1}{\color{blue}{e^{im}}}\right)\right)\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{e^{im} \cdot e^{im} - 1}{e^{im}}}\right)\right) \]
      8. distribute-neg-frac2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{e^{im} \cdot e^{im} - 1}{\mathsf{neg}\left(e^{im}\right)}} \]
      9. sub-negate-revN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{\color{blue}{\mathsf{neg}\left(\left(1 - e^{im} \cdot e^{im}\right)\right)}}{\mathsf{neg}\left(e^{im}\right)} \]
      10. frac-2neg-revN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{1 - e^{im} \cdot e^{im}}{e^{im}}} \]
      11. lower-/.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{1 - e^{im} \cdot e^{im}}{e^{im}}} \]
      12. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{\color{blue}{1 - e^{im} \cdot e^{im}}}{e^{im}} \]
      13. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{1 - \color{blue}{e^{im}} \cdot e^{im}}{e^{im}} \]
      14. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{1 - e^{im} \cdot \color{blue}{e^{im}}}{e^{im}} \]
      15. prod-expN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{1 - \color{blue}{e^{im + im}}}{e^{im}} \]
      16. lower-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{1 - \color{blue}{e^{im + im}}}{e^{im}} \]
      17. lower-+.f6441.0%

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \frac{1 - e^{\color{blue}{im + im}}}{e^{im}} \]
    3. Applied rewrites41.0%

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{1 - e^{im + im}}{e^{im}}} \]
    4. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \frac{1 - e^{im + im}}{e^{im}} \]
    5. Step-by-step derivation
      1. lower-*.f6433.7%

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot \frac{1 - e^{im + im}}{e^{im}} \]
    6. Applied rewrites33.7%

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \frac{1 - e^{im + im}}{e^{im}} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \frac{1 - e^{im + im}}{e^{im}}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{1 - e^{im + im}}{e^{im}} \cdot \left(\frac{1}{2} \cdot re\right)} \]
    8. Applied rewrites62.8%

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

    if -2e-175 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 5.0000000000000002e-5

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im \cdot \sin re\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(im \cdot \sin re\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\sin re \cdot im\right) \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \sin re \cdot \color{blue}{\left(\mathsf{neg}\left(im\right)\right)} \]
      6. lift-neg.f64N/A

        \[\leadsto \sin re \cdot \left(-im\right) \]
      7. lower-*.f6451.8%

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

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

    if 5.0000000000000002e-5 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)))

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \color{blue}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. lower-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
      5. lower-pow.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
    7. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. add-flipN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im - \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right)\right) \]
      3. sub-to-multN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      4. lower-unsound-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      5. lower-unsound--.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      6. lower-unsound-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)}{im}\right) \cdot im\right)\right) \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \left(\mathsf{neg}\left(\frac{-1}{6}\right)\right)}{im}\right) \cdot im\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      11. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      12. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      13. lift-pow.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      14. unpow2N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      15. associate-*r*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      16. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      17. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    9. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    10. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      3. associate-/l*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      5. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{\frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
      8. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
      10. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
      11. lower-/.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
    11. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - im \cdot \left(\left(re \cdot re\right) \cdot \frac{\frac{1}{6}}{im}\right)\right) \cdot im\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 74.7% accurate, 1.4× speedup?

\[\begin{array}{l} t_0 := \left(\left|im\right| \cdot re\right) \cdot re\\ t_1 := t\_0 \cdot \frac{-1}{6}\\ \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;\left|im\right| \leq 8400000000:\\ \;\;\;\;\sin re \cdot \left(-\left|im\right|\right)\\ \mathbf{elif}\;\left|im\right| \leq 380000000000000005108673117317708614502657882206222443035520544855956334316242777162531925831371834610731815469388147747294940629484994911226570500617535488:\\ \;\;\;\;-1 \cdot \left(re \cdot \left(\left(1 + \frac{\left|im\right|}{t\_1}\right) \cdot t\_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(re \cdot \frac{\left(\left|im\right| - t\_0 \cdot \frac{1}{6}\right) \cdot \left|im\right|}{\left|im\right|}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (* (* (fabs im) re) re)) (t_1 (* t_0 -1/6)))
  (*
   (copysign 1 im)
   (if (<= (fabs im) 8400000000)
     (* (sin re) (- (fabs im)))
     (if (<=
          (fabs im)
          380000000000000005108673117317708614502657882206222443035520544855956334316242777162531925831371834610731815469388147747294940629484994911226570500617535488)
       (* -1 (* re (* (+ 1 (/ (fabs im) t_1)) t_1)))
       (*
        -1
        (*
         re
         (/ (* (- (fabs im) (* t_0 1/6)) (fabs im)) (fabs im)))))))))
double code(double re, double im) {
	double t_0 = (fabs(im) * re) * re;
	double t_1 = t_0 * -0.16666666666666666;
	double tmp;
	if (fabs(im) <= 8400000000.0) {
		tmp = sin(re) * -fabs(im);
	} else if (fabs(im) <= 3.8e+155) {
		tmp = -1.0 * (re * ((1.0 + (fabs(im) / t_1)) * t_1));
	} else {
		tmp = -1.0 * (re * (((fabs(im) - (t_0 * 0.16666666666666666)) * fabs(im)) / fabs(im)));
	}
	return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
	double t_0 = (Math.abs(im) * re) * re;
	double t_1 = t_0 * -0.16666666666666666;
	double tmp;
	if (Math.abs(im) <= 8400000000.0) {
		tmp = Math.sin(re) * -Math.abs(im);
	} else if (Math.abs(im) <= 3.8e+155) {
		tmp = -1.0 * (re * ((1.0 + (Math.abs(im) / t_1)) * t_1));
	} else {
		tmp = -1.0 * (re * (((Math.abs(im) - (t_0 * 0.16666666666666666)) * Math.abs(im)) / Math.abs(im)));
	}
	return Math.copySign(1.0, im) * tmp;
}
def code(re, im):
	t_0 = (math.fabs(im) * re) * re
	t_1 = t_0 * -0.16666666666666666
	tmp = 0
	if math.fabs(im) <= 8400000000.0:
		tmp = math.sin(re) * -math.fabs(im)
	elif math.fabs(im) <= 3.8e+155:
		tmp = -1.0 * (re * ((1.0 + (math.fabs(im) / t_1)) * t_1))
	else:
		tmp = -1.0 * (re * (((math.fabs(im) - (t_0 * 0.16666666666666666)) * math.fabs(im)) / math.fabs(im)))
	return math.copysign(1.0, im) * tmp
function code(re, im)
	t_0 = Float64(Float64(abs(im) * re) * re)
	t_1 = Float64(t_0 * -0.16666666666666666)
	tmp = 0.0
	if (abs(im) <= 8400000000.0)
		tmp = Float64(sin(re) * Float64(-abs(im)));
	elseif (abs(im) <= 3.8e+155)
		tmp = Float64(-1.0 * Float64(re * Float64(Float64(1.0 + Float64(abs(im) / t_1)) * t_1)));
	else
		tmp = Float64(-1.0 * Float64(re * Float64(Float64(Float64(abs(im) - Float64(t_0 * 0.16666666666666666)) * abs(im)) / abs(im))));
	end
	return Float64(copysign(1.0, im) * tmp)
end
function tmp_2 = code(re, im)
	t_0 = (abs(im) * re) * re;
	t_1 = t_0 * -0.16666666666666666;
	tmp = 0.0;
	if (abs(im) <= 8400000000.0)
		tmp = sin(re) * -abs(im);
	elseif (abs(im) <= 3.8e+155)
		tmp = -1.0 * (re * ((1.0 + (abs(im) / t_1)) * t_1));
	else
		tmp = -1.0 * (re * (((abs(im) - (t_0 * 0.16666666666666666)) * abs(im)) / abs(im)));
	end
	tmp_2 = (sign(im) * abs(1.0)) * tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * -1/6), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[im], $MachinePrecision], 8400000000], N[(N[Sin[re], $MachinePrecision] * (-N[Abs[im], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Abs[im], $MachinePrecision], 380000000000000005108673117317708614502657882206222443035520544855956334316242777162531925831371834610731815469388147747294940629484994911226570500617535488], N[(-1 * N[(re * N[(N[(1 + N[(N[Abs[im], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1 * N[(re * N[(N[(N[(N[Abs[im], $MachinePrecision] - N[(t$95$0 * 1/6), $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] / N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|im\right| \cdot re\right) \cdot re\\
t_1 := t\_0 \cdot \frac{-1}{6}\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|im\right| \leq 8400000000:\\
\;\;\;\;\sin re \cdot \left(-\left|im\right|\right)\\

\mathbf{elif}\;\left|im\right| \leq 380000000000000005108673117317708614502657882206222443035520544855956334316242777162531925831371834610731815469388147747294940629484994911226570500617535488:\\
\;\;\;\;-1 \cdot \left(re \cdot \left(\left(1 + \frac{\left|im\right|}{t\_1}\right) \cdot t\_1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(re \cdot \frac{\left(\left|im\right| - t\_0 \cdot \frac{1}{6}\right) \cdot \left|im\right|}{\left|im\right|}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 8.4e9

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im \cdot \sin re\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(im \cdot \sin re\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\sin re \cdot im\right) \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \sin re \cdot \color{blue}{\left(\mathsf{neg}\left(im\right)\right)} \]
      6. lift-neg.f64N/A

        \[\leadsto \sin re \cdot \left(-im\right) \]
      7. lower-*.f6451.8%

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

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

    if 8.4e9 < im < 3.8000000000000001e155

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \color{blue}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. lower-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
      5. lower-pow.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
    7. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) + im\right)\right) \]
      3. sum-to-multN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right) \cdot \left(\frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right)\right) \]
      4. lower-unsound-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right) \cdot \left(\frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right)\right) \]
      5. lower-unsound-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right) \cdot \left(\frac{-1}{6} \cdot \left(\color{blue}{im} \cdot {re}^{2}\right)\right)\right)\right) \]
      6. lower-unsound-/.f6419.2%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      9. lower-*.f6419.2%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      10. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      11. lift-pow.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      14. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      15. lower-*.f6419.1%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right) \]
      16. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      18. lower-*.f6419.1%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      19. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      20. lift-pow.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      21. unpow2N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      22. associate-*r*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      24. lower-*.f6425.3%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 + \frac{im}{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}}\right) \cdot \left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6}\right)\right)\right) \]
    9. Applied rewrites25.3%

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

    if 3.8000000000000001e155 < im

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \color{blue}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. lower-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
      5. lower-pow.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
    7. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. add-flipN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im - \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right)\right) \]
      3. sub-to-multN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      4. lower-unsound-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      5. lower-unsound--.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      6. lower-unsound-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)}{im}\right) \cdot im\right)\right) \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \left(\mathsf{neg}\left(\frac{-1}{6}\right)\right)}{im}\right) \cdot im\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      11. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      12. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      13. lift-pow.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      14. unpow2N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      15. associate-*r*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      16. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      17. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    9. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    10. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      2. lift--.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      3. lift-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      4. sub-to-fractionN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\frac{1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im} \cdot im\right)\right) \]
      5. associate-*l/N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      6. lower-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      7. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      8. *-lft-identityN/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      9. lower--.f6446.6%

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
    11. Applied rewrites46.6%

      \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 53.0% accurate, 1.2× speedup?

\[\begin{array}{l} t_0 := im \cdot \left|re\right|\\ \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{578960446186581}{115792089237316195423570985008687907853269984665640564039457584007913129639936}:\\ \;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{\left(im - \left(t\_0 \cdot \left|re\right|\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-t\_0\\ \end{array} \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (* im (fabs re))))
  (*
   (copysign 1 re)
   (if (<=
        (* 1/2 (sin (fabs re)))
        578960446186581/115792089237316195423570985008687907853269984665640564039457584007913129639936)
     (*
      -1
      (* (fabs re) (/ (* (- im (* (* t_0 (fabs re)) 1/6)) im) im)))
     (- t_0)))))
double code(double re, double im) {
	double t_0 = im * fabs(re);
	double tmp;
	if ((0.5 * sin(fabs(re))) <= 5e-63) {
		tmp = -1.0 * (fabs(re) * (((im - ((t_0 * fabs(re)) * 0.16666666666666666)) * im) / im));
	} else {
		tmp = -t_0;
	}
	return copysign(1.0, re) * tmp;
}
public static double code(double re, double im) {
	double t_0 = im * Math.abs(re);
	double tmp;
	if ((0.5 * Math.sin(Math.abs(re))) <= 5e-63) {
		tmp = -1.0 * (Math.abs(re) * (((im - ((t_0 * Math.abs(re)) * 0.16666666666666666)) * im) / im));
	} else {
		tmp = -t_0;
	}
	return Math.copySign(1.0, re) * tmp;
}
def code(re, im):
	t_0 = im * math.fabs(re)
	tmp = 0
	if (0.5 * math.sin(math.fabs(re))) <= 5e-63:
		tmp = -1.0 * (math.fabs(re) * (((im - ((t_0 * math.fabs(re)) * 0.16666666666666666)) * im) / im))
	else:
		tmp = -t_0
	return math.copysign(1.0, re) * tmp
function code(re, im)
	t_0 = Float64(im * abs(re))
	tmp = 0.0
	if (Float64(0.5 * sin(abs(re))) <= 5e-63)
		tmp = Float64(-1.0 * Float64(abs(re) * Float64(Float64(Float64(im - Float64(Float64(t_0 * abs(re)) * 0.16666666666666666)) * im) / im)));
	else
		tmp = Float64(-t_0);
	end
	return Float64(copysign(1.0, re) * tmp)
end
function tmp_2 = code(re, im)
	t_0 = im * abs(re);
	tmp = 0.0;
	if ((0.5 * sin(abs(re))) <= 5e-63)
		tmp = -1.0 * (abs(re) * (((im - ((t_0 * abs(re)) * 0.16666666666666666)) * im) / im));
	else
		tmp = -t_0;
	end
	tmp_2 = (sign(re) * abs(1.0)) * tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 578960446186581/115792089237316195423570985008687907853269984665640564039457584007913129639936], N[(-1 * N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(im - N[(N[(t$95$0 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 1/6), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-t$95$0)]), $MachinePrecision]]
\begin{array}{l}
t_0 := im \cdot \left|re\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{578960446186581}{115792089237316195423570985008687907853269984665640564039457584007913129639936}:\\
\;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{\left(im - \left(t\_0 \cdot \left|re\right|\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right)\\

\mathbf{else}:\\
\;\;\;\;-t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.0000000000000002e-63

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \color{blue}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. lower-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
      5. lower-pow.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
    7. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. add-flipN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im - \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)\right)\right) \]
      3. sub-to-multN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      4. lower-unsound-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      5. lower-unsound--.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      6. lower-unsound-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}{im}\right) \cdot im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6}\right)}{im}\right) \cdot im\right)\right) \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \left(\mathsf{neg}\left(\frac{-1}{6}\right)\right)}{im}\right) \cdot im\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      11. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      12. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      13. lift-pow.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      14. unpow2N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      15. associate-*r*N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      16. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      17. lower-*.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    9. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
    10. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      2. lift--.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      3. lift-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\left(1 - \frac{\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im}\right) \cdot im\right)\right) \]
      4. sub-to-fractionN/A

        \[\leadsto -1 \cdot \left(re \cdot \left(\frac{1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}}{im} \cdot im\right)\right) \]
      5. associate-*l/N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      6. lower-/.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      7. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(1 \cdot im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      8. *-lft-identityN/A

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
      9. lower--.f6446.6%

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]
    11. Applied rewrites46.6%

      \[\leadsto -1 \cdot \left(re \cdot \frac{\left(im - \left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{1}{6}\right) \cdot im}{im}\right) \]

    if 5.0000000000000002e-63 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re))

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

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

        \[\leadsto -1 \cdot \left(im \cdot re\right) \]
    7. Applied rewrites33.2%

      \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot re\right)} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
      3. lower-neg.f6433.2%

        \[\leadsto -im \cdot re \]
    9. Applied rewrites33.2%

      \[\leadsto -im \cdot re \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 43.9% accurate, 1.3× speedup?

\[\begin{array}{l} t_0 := im \cdot \left|re\right|\\ \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{4722366482869645}{9444732965739290427392}:\\ \;\;\;\;-\left(\left(t\_0 \cdot \left|re\right|\right) \cdot \frac{-1}{6} + im\right) \cdot \left|re\right|\\ \mathbf{else}:\\ \;\;\;\;-t\_0\\ \end{array} \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (* im (fabs re))))
  (*
   (copysign 1 re)
   (if (<=
        (* 1/2 (sin (fabs re)))
        4722366482869645/9444732965739290427392)
     (- (* (+ (* (* t_0 (fabs re)) -1/6) im) (fabs re)))
     (- t_0)))))
double code(double re, double im) {
	double t_0 = im * fabs(re);
	double tmp;
	if ((0.5 * sin(fabs(re))) <= 5e-7) {
		tmp = -((((t_0 * fabs(re)) * -0.16666666666666666) + im) * fabs(re));
	} else {
		tmp = -t_0;
	}
	return copysign(1.0, re) * tmp;
}
public static double code(double re, double im) {
	double t_0 = im * Math.abs(re);
	double tmp;
	if ((0.5 * Math.sin(Math.abs(re))) <= 5e-7) {
		tmp = -((((t_0 * Math.abs(re)) * -0.16666666666666666) + im) * Math.abs(re));
	} else {
		tmp = -t_0;
	}
	return Math.copySign(1.0, re) * tmp;
}
def code(re, im):
	t_0 = im * math.fabs(re)
	tmp = 0
	if (0.5 * math.sin(math.fabs(re))) <= 5e-7:
		tmp = -((((t_0 * math.fabs(re)) * -0.16666666666666666) + im) * math.fabs(re))
	else:
		tmp = -t_0
	return math.copysign(1.0, re) * tmp
function code(re, im)
	t_0 = Float64(im * abs(re))
	tmp = 0.0
	if (Float64(0.5 * sin(abs(re))) <= 5e-7)
		tmp = Float64(-Float64(Float64(Float64(Float64(t_0 * abs(re)) * -0.16666666666666666) + im) * abs(re)));
	else
		tmp = Float64(-t_0);
	end
	return Float64(copysign(1.0, re) * tmp)
end
function tmp_2 = code(re, im)
	t_0 = im * abs(re);
	tmp = 0.0;
	if ((0.5 * sin(abs(re))) <= 5e-7)
		tmp = -((((t_0 * abs(re)) * -0.16666666666666666) + im) * abs(re));
	else
		tmp = -t_0;
	end
	tmp_2 = (sign(re) * abs(1.0)) * tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 4722366482869645/9444732965739290427392], (-N[(N[(N[(N[(t$95$0 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * -1/6), $MachinePrecision] + im), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), (-t$95$0)]), $MachinePrecision]]
\begin{array}{l}
t_0 := im \cdot \left|re\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{4722366482869645}{9444732965739290427392}:\\
\;\;\;\;-\left(\left(t\_0 \cdot \left|re\right|\right) \cdot \frac{-1}{6} + im\right) \cdot \left|re\right|\\

\mathbf{else}:\\
\;\;\;\;-t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 4.9999999999999998e-7

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \color{blue}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)}\right)\right) \]
      2. lower-+.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot \color{blue}{{re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
      5. lower-pow.f6436.7%

        \[\leadsto -1 \cdot \left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
    7. Applied rewrites36.7%

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right)} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)\right) \]
      3. lower-neg.f6436.7%

        \[\leadsto -re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto -re \cdot \left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto -\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
      6. lower-*.f6436.7%

        \[\leadsto -\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
      7. lift-+.f64N/A

        \[\leadsto -\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
      8. +-commutativeN/A

        \[\leadsto -\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) + im\right) \cdot re \]
      9. lower-+.f6436.7%

        \[\leadsto -\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) + im\right) \cdot re \]
      10. lift-*.f64N/A

        \[\leadsto -\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) + im\right) \cdot re \]
      11. *-commutativeN/A

        \[\leadsto -\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      12. lower-*.f6436.7%

        \[\leadsto -\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      13. lift-*.f64N/A

        \[\leadsto -\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      14. lift-pow.f64N/A

        \[\leadsto -\left(\left(im \cdot {re}^{2}\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      15. unpow2N/A

        \[\leadsto -\left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      16. associate-*r*N/A

        \[\leadsto -\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      17. lift-*.f64N/A

        \[\leadsto -\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
      18. lower-*.f6436.8%

        \[\leadsto -\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6} + im\right) \cdot re \]
    9. Applied rewrites36.8%

      \[\leadsto -\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot \frac{-1}{6} + im\right) \cdot re \]

    if 4.9999999999999998e-7 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re))

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      2. lower-*.f64N/A

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

        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
    4. Applied rewrites51.8%

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

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

        \[\leadsto -1 \cdot \left(im \cdot re\right) \]
    7. Applied rewrites33.2%

      \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(im \cdot re\right)} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
      3. lower-neg.f6433.2%

        \[\leadsto -im \cdot re \]
    9. Applied rewrites33.2%

      \[\leadsto -im \cdot re \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 33.2% accurate, 39.5× speedup?

\[-im \cdot re \]
(FPCore (re im)
  :precision binary64
  (- (* im re)))
double code(double re, double im) {
	return -(im * re);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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])
-im \cdot re
Derivation
  1. Initial program 65.9%

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

    \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
    2. lower-*.f64N/A

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

      \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
  4. Applied rewrites51.8%

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

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

      \[\leadsto -1 \cdot \left(im \cdot re\right) \]
  7. Applied rewrites33.2%

    \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto -1 \cdot \color{blue}{\left(im \cdot re\right)} \]
    2. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
    3. lower-neg.f6433.2%

      \[\leadsto -im \cdot re \]
  9. Applied rewrites33.2%

    \[\leadsto -im \cdot re \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64
  (* (* 1/2 (sin re)) (- (exp (- im)) (exp im))))