math.cos on complex, imaginary part

Percentage Accurate: 65.5% → 99.9%
Time: 4.1s
Alternatives: 10
Speedup: 1.3×

Specification

?
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(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));
}
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[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \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 10 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.5% accurate, 1.0× speedup?

\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(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));
}
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[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)

Alternative 1: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := \sin \left(\left|re\right|\right)\\ t_2 := \left(0.5 \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 -5 \cdot 10^{-248}:\\ \;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-11}:\\ \;\;\;\;t\_1 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im)))
       (t_1 (sin (fabs re)))
       (t_2 (* (* 0.5 t_1) (- (exp t_0) (exp (fabs im))))))
  (*
   (copysign 1.0 re)
   (*
    (copysign 1.0 im)
    (if (<= t_2 -5e-248)
      (/ (* (sinh (fabs im)) -2.0) (/ 2.0 (fabs re)))
      (if (<= t_2 2e-11)
        (* t_1 t_0)
        (*
         (sinh t_0)
         (*
          (fabs re)
          (+ 1.0 (* -0.16666666666666666 (pow (fabs re) 2.0)))))))))))
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 <= -5e-248) {
		tmp = (sinh(fabs(im)) * -2.0) / (2.0 / fabs(re));
	} else if (t_2 <= 2e-11) {
		tmp = t_1 * t_0;
	} else {
		tmp = sinh(t_0) * (fabs(re) * (1.0 + (-0.16666666666666666 * pow(fabs(re), 2.0))));
	}
	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 <= -5e-248) {
		tmp = (Math.sinh(Math.abs(im)) * -2.0) / (2.0 / Math.abs(re));
	} else if (t_2 <= 2e-11) {
		tmp = t_1 * t_0;
	} else {
		tmp = Math.sinh(t_0) * (Math.abs(re) * (1.0 + (-0.16666666666666666 * Math.pow(Math.abs(re), 2.0))));
	}
	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 <= -5e-248:
		tmp = (math.sinh(math.fabs(im)) * -2.0) / (2.0 / math.fabs(re))
	elif t_2 <= 2e-11:
		tmp = t_1 * t_0
	else:
		tmp = math.sinh(t_0) * (math.fabs(re) * (1.0 + (-0.16666666666666666 * math.pow(math.fabs(re), 2.0))))
	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 <= -5e-248)
		tmp = Float64(Float64(sinh(abs(im)) * -2.0) / Float64(2.0 / abs(re)));
	elseif (t_2 <= 2e-11)
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(sinh(t_0) * Float64(abs(re) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(re) ^ 2.0)))));
	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 <= -5e-248)
		tmp = (sinh(abs(im)) * -2.0) / (2.0 / abs(re));
	elseif (t_2 <= 2e-11)
		tmp = t_1 * t_0;
	else
		tmp = sinh(t_0) * (abs(re) * (1.0 + (-0.16666666666666666 * (abs(re) ^ 2.0))));
	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[(0.5 * 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.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -5e-248], N[(N[(N[Sinh[N[Abs[im], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] / N[(2.0 / N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-11], N[(t$95$1 * t$95$0), $MachinePrecision], N[(N[Sinh[t$95$0], $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 2.0], $MachinePrecision]), $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(0.5 \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 -5 \cdot 10^{-248}:\\
\;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t\_1 \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\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))) < -5.0000000000000001e-248

    1. Initial program 65.5%

      \[\left(0.5 \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. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)} \]
      6. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2}{\sin re \cdot \left(e^{-im} - e^{im}\right)}}} \]
    5. Applied rewrites99.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{2}{\sin re}}{-2 \cdot \sinh im}}} \]
      7. div-flip-revN/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{-2 \cdot \sinh im}}{\frac{2}{\sin re}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      12. lower-/.f64N/A

        \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{\sin re}}} \]
      13. lift-sin.f6499.8%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{\sin re}}} \]
    7. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\sinh im \cdot -2}{\frac{2}{\sin re}}} \]
    8. Taylor expanded in re around 0

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]
    9. Step-by-step derivation
      1. lower-/.f6462.3%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{re}}} \]
    10. Applied rewrites62.3%

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]

    if -5.0000000000000001e-248 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-11

    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

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

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

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

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

    1. Initial program 65.5%

      \[\left(0.5 \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. Taylor expanded in re around 0

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

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

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

        \[\leadsto \sinh \left(-im\right) \cdot \left(re \cdot \left(1 + \frac{-1}{6} \cdot \color{blue}{{re}^{2}}\right)\right) \]
      4. lower-pow.f6462.8%

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

      \[\leadsto \sinh \left(-im\right) \cdot \color{blue}{\left(re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 98.6% accurate, 1.3× 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.5%

    \[\left(0.5 \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 3: 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(0.5 \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 -5 \cdot 10^{-248}:\\ \;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-11}:\\ \;\;\;\;t\_1 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|im\right| \cdot \left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|re\right|\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im)))
       (t_1 (sin (fabs re)))
       (t_2 (* (* 0.5 t_1) (- (exp t_0) (exp (fabs im))))))
  (*
   (copysign 1.0 re)
   (*
    (copysign 1.0 im)
    (if (<= t_2 -5e-248)
      (/ (* (sinh (fabs im)) -2.0) (/ 2.0 (fabs re)))
      (if (<= t_2 2e-11)
        (* t_1 t_0)
        (*
         (fabs im)
         (-
          (*
           (* (* (fabs re) (fabs re)) (fabs re))
           0.16666666666666666)
          (fabs re)))))))))
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 <= -5e-248) {
		tmp = (sinh(fabs(im)) * -2.0) / (2.0 / fabs(re));
	} else if (t_2 <= 2e-11) {
		tmp = t_1 * t_0;
	} else {
		tmp = fabs(im) * ((((fabs(re) * fabs(re)) * fabs(re)) * 0.16666666666666666) - fabs(re));
	}
	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 <= -5e-248) {
		tmp = (Math.sinh(Math.abs(im)) * -2.0) / (2.0 / Math.abs(re));
	} else if (t_2 <= 2e-11) {
		tmp = t_1 * t_0;
	} else {
		tmp = Math.abs(im) * ((((Math.abs(re) * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - Math.abs(re));
	}
	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 <= -5e-248:
		tmp = (math.sinh(math.fabs(im)) * -2.0) / (2.0 / math.fabs(re))
	elif t_2 <= 2e-11:
		tmp = t_1 * t_0
	else:
		tmp = math.fabs(im) * ((((math.fabs(re) * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - math.fabs(re))
	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 <= -5e-248)
		tmp = Float64(Float64(sinh(abs(im)) * -2.0) / Float64(2.0 / abs(re)));
	elseif (t_2 <= 2e-11)
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(abs(im) * Float64(Float64(Float64(Float64(abs(re) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(re)));
	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 <= -5e-248)
		tmp = (sinh(abs(im)) * -2.0) / (2.0 / abs(re));
	elseif (t_2 <= 2e-11)
		tmp = t_1 * t_0;
	else
		tmp = abs(im) * ((((abs(re) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(re));
	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[(0.5 * 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.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -5e-248], N[(N[(N[Sinh[N[Abs[im], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] / N[(2.0 / N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-11], N[(t$95$1 * t$95$0), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := \sin \left(\left|re\right|\right)\\
t_2 := \left(0.5 \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 -5 \cdot 10^{-248}:\\
\;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t\_1 \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\left|im\right| \cdot \left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|re\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))) < -5.0000000000000001e-248

    1. Initial program 65.5%

      \[\left(0.5 \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. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)} \]
      6. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2}{\sin re \cdot \left(e^{-im} - e^{im}\right)}}} \]
    5. Applied rewrites99.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{2}{\sin re}}{-2 \cdot \sinh im}}} \]
      7. div-flip-revN/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{-2 \cdot \sinh im}}{\frac{2}{\sin re}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      12. lower-/.f64N/A

        \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{\sin re}}} \]
      13. lift-sin.f6499.8%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{\sin re}}} \]
    7. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\sinh im \cdot -2}{\frac{2}{\sin re}}} \]
    8. Taylor expanded in re around 0

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]
    9. Step-by-step derivation
      1. lower-/.f6462.3%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{re}}} \]
    10. Applied rewrites62.3%

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]

    if -5.0000000000000001e-248 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-11

    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

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

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

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

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

    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

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

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

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

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

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

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
      5. lower-pow.f6436.8%

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
    7. Applied rewrites36.8%

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

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

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

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

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

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

        \[\leadsto re \cdot \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) + \left(\mathsf{neg}\left(im\right)\right) \cdot re \]
      7. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

        \[\leadsto \left(\left(im \cdot {re}^{2}\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
      15. lift-*.f64N/A

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

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

        \[\leadsto \left(\left({re}^{2} \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
      18. lift-pow.f64N/A

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

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

        \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
      21. lift-*.f64N/A

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

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

        \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - re \cdot im \]
    9. Applied rewrites30.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\left(re \cdot re\right) \cdot \left(\frac{1}{6} \cdot re\right)\right) - im \cdot re \]
      10. distribute-lft-out--N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\left(\left(re \cdot re\right) \cdot re\right) \cdot 0.16666666666666666 - re\right) \]
    11. Applied rewrites36.8%

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

Alternative 4: 73.3% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right) \leq -5 \cdot 10^{-248}:\\ \;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\ \mathbf{else}:\\ \;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im))))
  (*
   (copysign 1.0 re)
   (*
    (copysign 1.0 im)
    (if (<=
         (* (* 0.5 (sin (fabs re))) (- (exp t_0) (exp (fabs im))))
         -5e-248)
      (/ (* (sinh (fabs im)) -2.0) (/ 2.0 (fabs re)))
      (*
       (fabs re)
       (fma
        (* (* 0.16666666666666666 (fabs im)) (fabs re))
        (fabs re)
        t_0)))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double tmp;
	if (((0.5 * sin(fabs(re))) * (exp(t_0) - exp(fabs(im)))) <= -5e-248) {
		tmp = (sinh(fabs(im)) * -2.0) / (2.0 / fabs(re));
	} else {
		tmp = fabs(re) * fma(((0.16666666666666666 * fabs(im)) * fabs(re)), fabs(re), t_0);
	}
	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
function code(re, im)
	t_0 = Float64(-abs(im))
	tmp = 0.0
	if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(t_0) - exp(abs(im)))) <= -5e-248)
		tmp = Float64(Float64(sinh(abs(im)) * -2.0) / Float64(2.0 / abs(re)));
	else
		tmp = Float64(abs(re) * fma(Float64(Float64(0.16666666666666666 * abs(im)) * abs(re)), abs(re), t_0));
	end
	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-248], N[(N[(N[Sinh[N[Abs[im], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] / N[(2.0 / N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(0.16666666666666666 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := -\left|im\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right) \leq -5 \cdot 10^{-248}:\\
\;\;\;\;\frac{\sinh \left(\left|im\right|\right) \cdot -2}{\frac{2}{\left|re\right|}}\\

\mathbf{else}:\\
\;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\


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

    1. Initial program 65.5%

      \[\left(0.5 \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. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)} \]
      6. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2}{\sin re \cdot \left(e^{-im} - e^{im}\right)}}} \]
    5. Applied rewrites99.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{2}{\sin re}}{-2 \cdot \sinh im}}} \]
      7. div-flip-revN/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \sinh im}{\frac{2}{\sin re}}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{-2 \cdot \sinh im}}{\frac{2}{\sin re}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sinh im \cdot -2}}{\frac{2}{\sin re}} \]
      12. lower-/.f64N/A

        \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{\sin re}}} \]
      13. lift-sin.f6499.8%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{\sin re}}} \]
    7. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\sinh im \cdot -2}{\frac{2}{\sin re}}} \]
    8. Taylor expanded in re around 0

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]
    9. Step-by-step derivation
      1. lower-/.f6462.3%

        \[\leadsto \frac{\sinh im \cdot -2}{\frac{2}{\color{blue}{re}}} \]
    10. Applied rewrites62.3%

      \[\leadsto \frac{\sinh im \cdot -2}{\color{blue}{\frac{2}{re}}} \]

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

    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

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

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

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

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

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

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
      5. lower-pow.f6436.8%

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
    7. Applied rewrites36.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, -1 \cdot im\right) \]
      12. mul-1-negN/A

        \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, \mathsf{neg}\left(im\right)\right) \]
      13. lower-neg.f6436.8%

        \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
    9. Applied rewrites36.8%

      \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 73.3% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right) \leq -5 \cdot 10^{-248}:\\ \;\;\;\;\left(-2 \cdot \sinh \left(\left|im\right|\right)\right) \cdot \left(0.5 \cdot \left|re\right|\right)\\ \mathbf{else}:\\ \;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im))))
  (*
   (copysign 1.0 re)
   (*
    (copysign 1.0 im)
    (if (<=
         (* (* 0.5 (sin (fabs re))) (- (exp t_0) (exp (fabs im))))
         -5e-248)
      (* (* -2.0 (sinh (fabs im))) (* 0.5 (fabs re)))
      (*
       (fabs re)
       (fma
        (* (* 0.16666666666666666 (fabs im)) (fabs re))
        (fabs re)
        t_0)))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double tmp;
	if (((0.5 * sin(fabs(re))) * (exp(t_0) - exp(fabs(im)))) <= -5e-248) {
		tmp = (-2.0 * sinh(fabs(im))) * (0.5 * fabs(re));
	} else {
		tmp = fabs(re) * fma(((0.16666666666666666 * fabs(im)) * fabs(re)), fabs(re), t_0);
	}
	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
function code(re, im)
	t_0 = Float64(-abs(im))
	tmp = 0.0
	if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(t_0) - exp(abs(im)))) <= -5e-248)
		tmp = Float64(Float64(-2.0 * sinh(abs(im))) * Float64(0.5 * abs(re)));
	else
		tmp = Float64(abs(re) * fma(Float64(Float64(0.16666666666666666 * abs(im)) * abs(re)), abs(re), t_0));
	end
	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-248], N[(N[(-2.0 * N[Sinh[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(0.16666666666666666 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := -\left|im\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - e^{\left|im\right|}\right) \leq -5 \cdot 10^{-248}:\\
\;\;\;\;\left(-2 \cdot \sinh \left(\left|im\right|\right)\right) \cdot \left(0.5 \cdot \left|re\right|\right)\\

\mathbf{else}:\\
\;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\


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

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot 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 re\right)} \]
      3. lower-*.f6451.4%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)} \]
      4. lift--.f64N/A

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

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

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{2 \cdot \sinh im}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. distribute-lft-neg-inN/A

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

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

        \[\leadsto \left(\color{blue}{-2} \cdot \sinh im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. lower-sinh.f6462.4%

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    6. Applied rewrites62.4%

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

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

    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

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

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

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

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

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

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
      5. lower-pow.f6436.8%

        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
    7. Applied rewrites36.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, -1 \cdot im\right) \]
      12. mul-1-negN/A

        \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, \mathsf{neg}\left(im\right)\right) \]
      13. lower-neg.f6436.8%

        \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
    9. Applied rewrites36.8%

      \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 72.9% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := e^{\left|im\right|}\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - t\_1\right) \leq -1 \cdot 10^{-42}:\\ \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\ \mathbf{else}:\\ \;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im))) (t_1 (exp (fabs im))))
  (*
   (copysign 1.0 re)
   (*
    (copysign 1.0 im)
    (if (<= (* (* 0.5 (sin (fabs re))) (- (exp t_0) t_1)) -1e-42)
      (* (* 0.5 (fabs re)) (- 1.0 t_1))
      (*
       (fabs re)
       (fma
        (* (* 0.16666666666666666 (fabs im)) (fabs re))
        (fabs re)
        t_0)))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double t_1 = exp(fabs(im));
	double tmp;
	if (((0.5 * sin(fabs(re))) * (exp(t_0) - t_1)) <= -1e-42) {
		tmp = (0.5 * fabs(re)) * (1.0 - t_1);
	} else {
		tmp = fabs(re) * fma(((0.16666666666666666 * fabs(im)) * fabs(re)), fabs(re), t_0);
	}
	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
function code(re, im)
	t_0 = Float64(-abs(im))
	t_1 = exp(abs(im))
	tmp = 0.0
	if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(t_0) - t_1)) <= -1e-42)
		tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1));
	else
		tmp = Float64(abs(re) * fma(Float64(Float64(0.16666666666666666 * abs(im)) * abs(re)), abs(re), t_0));
	end
	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], -1e-42], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(0.16666666666666666 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := e^{\left|im\right|}\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{t\_0} - t\_1\right) \leq -1 \cdot 10^{-42}:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\

\mathbf{else}:\\
\;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left|im\right|\right) \cdot \left|re\right|, \left|re\right|, t\_0\right)\\


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

    1. Initial program 65.5%

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

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

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

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \left(\color{blue}{1} - e^{im}\right) \]
    6. Step-by-step derivation
      1. Applied rewrites33.2%

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

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

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
        5. lower-pow.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
      7. Applied rewrites36.8%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, -1 \cdot im\right) \]
        12. mul-1-negN/A

          \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, \mathsf{neg}\left(im\right)\right) \]
        13. lower-neg.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
      9. Applied rewrites36.8%

        \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 7: 43.6% accurate, 1.0× speedup?

    \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\ \;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot \left|re\right|, \left|re\right|, -im\right)\\ \mathbf{else}:\\ \;\;\;\;-\left|re\right| \cdot im\\ \end{array} \]
    (FPCore (re im)
      :precision binary64
      (*
     (copysign 1.0 re)
     (if (<= (* 0.5 (sin (fabs re))) 0.0005)
       (*
        (fabs re)
        (fma (* (* 0.16666666666666666 im) (fabs re)) (fabs re) (- im)))
       (- (* (fabs re) im)))))
    double code(double re, double im) {
    	double tmp;
    	if ((0.5 * sin(fabs(re))) <= 0.0005) {
    		tmp = fabs(re) * fma(((0.16666666666666666 * im) * fabs(re)), fabs(re), -im);
    	} else {
    		tmp = -(fabs(re) * im);
    	}
    	return copysign(1.0, re) * tmp;
    }
    
    function code(re, im)
    	tmp = 0.0
    	if (Float64(0.5 * sin(abs(re))) <= 0.0005)
    		tmp = Float64(abs(re) * fma(Float64(Float64(0.16666666666666666 * im) * abs(re)), abs(re), Float64(-im)));
    	else
    		tmp = Float64(-Float64(abs(re) * im));
    	end
    	return Float64(copysign(1.0, re) * tmp)
    end
    
    code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0005], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + (-im)), $MachinePrecision]), $MachinePrecision], (-N[(N[Abs[re], $MachinePrecision] * im), $MachinePrecision])]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
    \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\
    \;\;\;\;\left|re\right| \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot \left|re\right|, \left|re\right|, -im\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;-\left|re\right| \cdot im\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.0000000000000001e-4

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
        5. lower-pow.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
      7. Applied rewrites36.8%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, -1 \cdot im\right) \]
        12. mul-1-negN/A

          \[\leadsto re \cdot \mathsf{fma}\left(\left(\frac{1}{6} \cdot im\right) \cdot re, re, \mathsf{neg}\left(im\right)\right) \]
        13. lower-neg.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]
      9. Applied rewrites36.8%

        \[\leadsto re \cdot \mathsf{fma}\left(\left(0.16666666666666666 \cdot im\right) \cdot re, re, -im\right) \]

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

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

        \[\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-*.f6432.3%

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

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

          \[\leadsto -im \cdot re \]
        4. lift-*.f64N/A

          \[\leadsto -im \cdot re \]
        5. *-commutativeN/A

          \[\leadsto -re \cdot im \]
        6. lower-*.f6432.3%

          \[\leadsto -re \cdot im \]
      9. Applied rewrites32.3%

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

    Alternative 8: 43.6% accurate, 1.0× speedup?

    \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\ \;\;\;\;\left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot im\right) \cdot 0.16666666666666666 - im\right) \cdot \left|re\right|\\ \mathbf{else}:\\ \;\;\;\;-\left|re\right| \cdot im\\ \end{array} \]
    (FPCore (re im)
      :precision binary64
      (*
     (copysign 1.0 re)
     (if (<= (* 0.5 (sin (fabs re))) 0.0005)
       (*
        (- (* (* (* (fabs re) (fabs re)) im) 0.16666666666666666) im)
        (fabs re))
       (- (* (fabs re) im)))))
    double code(double re, double im) {
    	double tmp;
    	if ((0.5 * sin(fabs(re))) <= 0.0005) {
    		tmp = ((((fabs(re) * fabs(re)) * im) * 0.16666666666666666) - im) * fabs(re);
    	} else {
    		tmp = -(fabs(re) * im);
    	}
    	return copysign(1.0, re) * tmp;
    }
    
    public static double code(double re, double im) {
    	double tmp;
    	if ((0.5 * Math.sin(Math.abs(re))) <= 0.0005) {
    		tmp = ((((Math.abs(re) * Math.abs(re)) * im) * 0.16666666666666666) - im) * Math.abs(re);
    	} else {
    		tmp = -(Math.abs(re) * im);
    	}
    	return Math.copySign(1.0, re) * tmp;
    }
    
    def code(re, im):
    	tmp = 0
    	if (0.5 * math.sin(math.fabs(re))) <= 0.0005:
    		tmp = ((((math.fabs(re) * math.fabs(re)) * im) * 0.16666666666666666) - im) * math.fabs(re)
    	else:
    		tmp = -(math.fabs(re) * im)
    	return math.copysign(1.0, re) * tmp
    
    function code(re, im)
    	tmp = 0.0
    	if (Float64(0.5 * sin(abs(re))) <= 0.0005)
    		tmp = Float64(Float64(Float64(Float64(Float64(abs(re) * abs(re)) * im) * 0.16666666666666666) - im) * abs(re));
    	else
    		tmp = Float64(-Float64(abs(re) * im));
    	end
    	return Float64(copysign(1.0, re) * tmp)
    end
    
    function tmp_2 = code(re, im)
    	tmp = 0.0;
    	if ((0.5 * sin(abs(re))) <= 0.0005)
    		tmp = ((((abs(re) * abs(re)) * im) * 0.16666666666666666) - im) * abs(re);
    	else
    		tmp = -(abs(re) * im);
    	end
    	tmp_2 = (sign(re) * abs(1.0)) * tmp;
    end
    
    code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0005], N[(N[(N[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision], (-N[(N[Abs[re], $MachinePrecision] * im), $MachinePrecision])]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
    \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\
    \;\;\;\;\left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot im\right) \cdot 0.16666666666666666 - im\right) \cdot \left|re\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;-\left|re\right| \cdot im\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.0000000000000001e-4

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
        5. lower-pow.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
      7. Applied rewrites36.8%

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

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

          \[\leadsto \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
        3. lower-*.f6436.8%

          \[\leadsto \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
        4. lift-fma.f64N/A

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

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

          \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right) + \left(\mathsf{neg}\left(im\right)\right)\right) \cdot re \]
        7. sub-flip-reverseN/A

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

          \[\leadsto \left(0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right) - im\right) \cdot re \]
        9. lift-*.f64N/A

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

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

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

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

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

          \[\leadsto \left(\left({re}^{2} \cdot im\right) \cdot 0.16666666666666666 - im\right) \cdot re \]
        15. lift-pow.f64N/A

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

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

          \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666 - im\right) \cdot re \]
      9. Applied rewrites36.8%

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

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

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

        \[\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-*.f6432.3%

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

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

          \[\leadsto -im \cdot re \]
        4. lift-*.f64N/A

          \[\leadsto -im \cdot re \]
        5. *-commutativeN/A

          \[\leadsto -re \cdot im \]
        6. lower-*.f6432.3%

          \[\leadsto -re \cdot im \]
      9. Applied rewrites32.3%

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

    Alternative 9: 43.6% accurate, 1.0× speedup?

    \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\ \;\;\;\;im \cdot \left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|re\right|\right)\\ \mathbf{else}:\\ \;\;\;\;-\left|re\right| \cdot im\\ \end{array} \]
    (FPCore (re im)
      :precision binary64
      (*
     (copysign 1.0 re)
     (if (<= (* 0.5 (sin (fabs re))) 0.0005)
       (*
        im
        (-
         (* (* (* (fabs re) (fabs re)) (fabs re)) 0.16666666666666666)
         (fabs re)))
       (- (* (fabs re) im)))))
    double code(double re, double im) {
    	double tmp;
    	if ((0.5 * sin(fabs(re))) <= 0.0005) {
    		tmp = im * ((((fabs(re) * fabs(re)) * fabs(re)) * 0.16666666666666666) - fabs(re));
    	} else {
    		tmp = -(fabs(re) * im);
    	}
    	return copysign(1.0, re) * tmp;
    }
    
    public static double code(double re, double im) {
    	double tmp;
    	if ((0.5 * Math.sin(Math.abs(re))) <= 0.0005) {
    		tmp = im * ((((Math.abs(re) * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - Math.abs(re));
    	} else {
    		tmp = -(Math.abs(re) * im);
    	}
    	return Math.copySign(1.0, re) * tmp;
    }
    
    def code(re, im):
    	tmp = 0
    	if (0.5 * math.sin(math.fabs(re))) <= 0.0005:
    		tmp = im * ((((math.fabs(re) * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - math.fabs(re))
    	else:
    		tmp = -(math.fabs(re) * im)
    	return math.copysign(1.0, re) * tmp
    
    function code(re, im)
    	tmp = 0.0
    	if (Float64(0.5 * sin(abs(re))) <= 0.0005)
    		tmp = Float64(im * Float64(Float64(Float64(Float64(abs(re) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(re)));
    	else
    		tmp = Float64(-Float64(abs(re) * im));
    	end
    	return Float64(copysign(1.0, re) * tmp)
    end
    
    function tmp_2 = code(re, im)
    	tmp = 0.0;
    	if ((0.5 * sin(abs(re))) <= 0.0005)
    		tmp = im * ((((abs(re) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(re));
    	else
    		tmp = -(abs(re) * im);
    	end
    	tmp_2 = (sign(re) * abs(1.0)) * tmp;
    end
    
    code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0005], N[(im * N[(N[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(N[Abs[re], $MachinePrecision] * im), $MachinePrecision])]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
    \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 0.0005:\\
    \;\;\;\;im \cdot \left(\left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|re\right|\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;-\left|re\right| \cdot im\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.0000000000000001e-4

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

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

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

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

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

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

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \]
        5. lower-pow.f6436.8%

          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
      7. Applied rewrites36.8%

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

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

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

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

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

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

          \[\leadsto re \cdot \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) + \left(\mathsf{neg}\left(im\right)\right) \cdot re \]
        7. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

          \[\leadsto \left(\left(im \cdot {re}^{2}\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
        15. lift-*.f64N/A

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

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

          \[\leadsto \left(\left({re}^{2} \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
        18. lift-pow.f64N/A

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

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

          \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - im \cdot re \]
        21. lift-*.f64N/A

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

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

          \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re - re \cdot im \]
      9. Applied rewrites30.1%

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

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

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

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

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

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

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

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

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

          \[\leadsto im \cdot \left(\left(re \cdot re\right) \cdot \left(\frac{1}{6} \cdot re\right)\right) - im \cdot re \]
        10. distribute-lft-out--N/A

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto im \cdot \left(\left(\left(re \cdot re\right) \cdot re\right) \cdot 0.16666666666666666 - re\right) \]
      11. Applied rewrites36.8%

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

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

      1. Initial program 65.5%

        \[\left(0.5 \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.3%

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

        \[\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-*.f6432.3%

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

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

          \[\leadsto -im \cdot re \]
        4. lift-*.f64N/A

          \[\leadsto -im \cdot re \]
        5. *-commutativeN/A

          \[\leadsto -re \cdot im \]
        6. lower-*.f6432.3%

          \[\leadsto -re \cdot im \]
      9. Applied rewrites32.3%

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

    Alternative 10: 32.3% accurate, 13.2× speedup?

    \[-re \cdot im \]
    (FPCore (re im)
      :precision binary64
      (- (* re im)))
    double code(double re, double im) {
    	return -(re * 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 = -(re * im)
    end function
    
    public static double code(double re, double im) {
    	return -(re * im);
    }
    
    def code(re, im):
    	return -(re * im)
    
    function code(re, im)
    	return Float64(-Float64(re * im))
    end
    
    function tmp = code(re, im)
    	tmp = -(re * im);
    end
    
    code[re_, im_] := (-N[(re * im), $MachinePrecision])
    
    -re \cdot im
    
    Derivation
    1. Initial program 65.5%

      \[\left(0.5 \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.3%

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

      \[\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-*.f6432.3%

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

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

        \[\leadsto -im \cdot re \]
      4. lift-*.f64N/A

        \[\leadsto -im \cdot re \]
      5. *-commutativeN/A

        \[\leadsto -re \cdot im \]
      6. lower-*.f6432.3%

        \[\leadsto -re \cdot im \]
    9. Applied rewrites32.3%

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

    Reproduce

    ?
    herbie shell --seed 2025224 
    (FPCore (re im)
      :name "math.cos on complex, imaginary part"
      :precision binary64
      (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))