math.cos on complex, imaginary part

Percentage Accurate: 66.4% → 99.9%
Time: 1.1min
Alternatives: 6
Speedup: 1.5×

Specification

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

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 66.4% accurate, 1.0× speedup?

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

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 71.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|im\right|\right) \cdot \frac{-1}{6}\\ t_2 := \sin \left(\left|re\right|\right)\\ t_3 := \left(\frac{1}{2} \cdot t\_2\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\_3 \leq -\infty:\\ \;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{t\_1 \cdot t\_1 - \left|im\right| \cdot \left|im\right|}{t\_1 - \left|im\right|}\right)\\ \mathbf{elif}\;t\_3 \leq 500000000:\\ \;\;\;\;t\_2 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(\frac{-1}{6} \cdot \left(\left|im\right| \cdot {\left(\left|re\right|\right)}^{3}\right)\right)\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im)))
       (t_1 (* (* (* (fabs re) (fabs re)) (fabs im)) -1/6))
       (t_2 (sin (fabs re)))
       (t_3 (* (* 1/2 t_2) (- (exp t_0) (exp (fabs im))))))
  (*
   (copysign 1 re)
   (*
    (copysign 1 im)
    (if (<= t_3 (- INFINITY))
      (*
       -1
       (*
        (fabs re)
        (/
         (- (* t_1 t_1) (* (fabs im) (fabs im)))
         (- t_1 (fabs im)))))
      (if (<= t_3 500000000)
        (* t_2 t_0)
        (* -1 (* -1/6 (* (fabs im) (pow (fabs re) 3))))))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double t_1 = ((fabs(re) * fabs(re)) * fabs(im)) * -0.16666666666666666;
	double t_2 = sin(fabs(re));
	double t_3 = (0.5 * t_2) * (exp(t_0) - exp(fabs(im)));
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = -1.0 * (fabs(re) * (((t_1 * t_1) - (fabs(im) * fabs(im))) / (t_1 - fabs(im))));
	} else if (t_3 <= 500000000.0) {
		tmp = t_2 * t_0;
	} else {
		tmp = -1.0 * (-0.16666666666666666 * (fabs(im) * pow(fabs(re), 3.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.abs(re) * Math.abs(re)) * Math.abs(im)) * -0.16666666666666666;
	double t_2 = Math.sin(Math.abs(re));
	double t_3 = (0.5 * t_2) * (Math.exp(t_0) - Math.exp(Math.abs(im)));
	double tmp;
	if (t_3 <= -Double.POSITIVE_INFINITY) {
		tmp = -1.0 * (Math.abs(re) * (((t_1 * t_1) - (Math.abs(im) * Math.abs(im))) / (t_1 - Math.abs(im))));
	} else if (t_3 <= 500000000.0) {
		tmp = t_2 * t_0;
	} else {
		tmp = -1.0 * (-0.16666666666666666 * (Math.abs(im) * Math.pow(Math.abs(re), 3.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.fabs(re) * math.fabs(re)) * math.fabs(im)) * -0.16666666666666666
	t_2 = math.sin(math.fabs(re))
	t_3 = (0.5 * t_2) * (math.exp(t_0) - math.exp(math.fabs(im)))
	tmp = 0
	if t_3 <= -math.inf:
		tmp = -1.0 * (math.fabs(re) * (((t_1 * t_1) - (math.fabs(im) * math.fabs(im))) / (t_1 - math.fabs(im))))
	elif t_3 <= 500000000.0:
		tmp = t_2 * t_0
	else:
		tmp = -1.0 * (-0.16666666666666666 * (math.fabs(im) * math.pow(math.fabs(re), 3.0)))
	return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
function code(re, im)
	t_0 = Float64(-abs(im))
	t_1 = Float64(Float64(Float64(abs(re) * abs(re)) * abs(im)) * -0.16666666666666666)
	t_2 = sin(abs(re))
	t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - exp(abs(im))))
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = Float64(-1.0 * Float64(abs(re) * Float64(Float64(Float64(t_1 * t_1) - Float64(abs(im) * abs(im))) / Float64(t_1 - abs(im)))));
	elseif (t_3 <= 500000000.0)
		tmp = Float64(t_2 * t_0);
	else
		tmp = Float64(-1.0 * Float64(-0.16666666666666666 * Float64(abs(im) * (abs(re) ^ 3.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 = ((abs(re) * abs(re)) * abs(im)) * -0.16666666666666666;
	t_2 = sin(abs(re));
	t_3 = (0.5 * t_2) * (exp(t_0) - exp(abs(im)));
	tmp = 0.0;
	if (t_3 <= -Inf)
		tmp = -1.0 * (abs(re) * (((t_1 * t_1) - (abs(im) * abs(im))) / (t_1 - abs(im))));
	elseif (t_3 <= 500000000.0)
		tmp = t_2 * t_0;
	else
		tmp = -1.0 * (-0.16666666666666666 * (abs(im) * (abs(re) ^ 3.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[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -1/6), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(1/2 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(-1 * N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 500000000], N[(t$95$2 * t$95$0), $MachinePrecision], N[(-1 * N[(-1/6 * N[(N[Abs[im], $MachinePrecision] * N[Power[N[Abs[re], $MachinePrecision], 3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|im\right|\right) \cdot \frac{-1}{6}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(\frac{1}{2} \cdot t\_2\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\_3 \leq -\infty:\\
\;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{t\_1 \cdot t\_1 - \left|im\right| \cdot \left|im\right|}{t\_1 - \left|im\right|}\right)\\

\mathbf{elif}\;t\_3 \leq 500000000:\\
\;\;\;\;t\_2 \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\frac{-1}{6} \cdot \left(\left|im\right| \cdot {\left(\left|re\right|\right)}^{3}\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))) < -inf.0

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) - im \cdot im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) - \color{blue}{im}}\right) \]
    9. Applied rewrites35.5%

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -1 \cdot \left(re \cdot \color{blue}{\left(im + \frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)}\right) \]
    8. Taylor expanded in re around inf

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

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

        \[\leadsto -1 \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{3}\right)\right) \]
      3. lower-pow.f6424.7%

        \[\leadsto -1 \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{3}\right)\right) \]
    10. Applied rewrites24.7%

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

Alternative 3: 71.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|im\right|\right) \cdot \frac{-1}{6}\\ t_2 := \sin \left(\left|re\right|\right)\\ t_3 := \left(\frac{1}{2} \cdot t\_2\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\_3 \leq -\infty:\\ \;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{t\_1 \cdot t\_1 - \left|im\right| \cdot \left|im\right|}{t\_1 - \left|im\right|}\right)\\ \mathbf{elif}\;t\_3 \leq 500000000:\\ \;\;\;\;t\_2 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;-\left(\left(\left(\frac{-1}{6} \cdot \left|im\right|\right) \cdot \left|re\right|\right) \cdot \left|re\right| + \left|im\right|\right) \cdot \left|re\right|\\ \end{array}\right) \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (- (fabs im)))
       (t_1 (* (* (* (fabs re) (fabs re)) (fabs im)) -1/6))
       (t_2 (sin (fabs re)))
       (t_3 (* (* 1/2 t_2) (- (exp t_0) (exp (fabs im))))))
  (*
   (copysign 1 re)
   (*
    (copysign 1 im)
    (if (<= t_3 (- INFINITY))
      (*
       -1
       (*
        (fabs re)
        (/
         (- (* t_1 t_1) (* (fabs im) (fabs im)))
         (- t_1 (fabs im)))))
      (if (<= t_3 500000000)
        (* t_2 t_0)
        (-
         (*
          (+ (* (* (* -1/6 (fabs im)) (fabs re)) (fabs re)) (fabs im))
          (fabs re)))))))))
double code(double re, double im) {
	double t_0 = -fabs(im);
	double t_1 = ((fabs(re) * fabs(re)) * fabs(im)) * -0.16666666666666666;
	double t_2 = sin(fabs(re));
	double t_3 = (0.5 * t_2) * (exp(t_0) - exp(fabs(im)));
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = -1.0 * (fabs(re) * (((t_1 * t_1) - (fabs(im) * fabs(im))) / (t_1 - fabs(im))));
	} else if (t_3 <= 500000000.0) {
		tmp = t_2 * t_0;
	} else {
		tmp = -(((((-0.16666666666666666 * fabs(im)) * fabs(re)) * fabs(re)) + fabs(im)) * 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.abs(re) * Math.abs(re)) * Math.abs(im)) * -0.16666666666666666;
	double t_2 = Math.sin(Math.abs(re));
	double t_3 = (0.5 * t_2) * (Math.exp(t_0) - Math.exp(Math.abs(im)));
	double tmp;
	if (t_3 <= -Double.POSITIVE_INFINITY) {
		tmp = -1.0 * (Math.abs(re) * (((t_1 * t_1) - (Math.abs(im) * Math.abs(im))) / (t_1 - Math.abs(im))));
	} else if (t_3 <= 500000000.0) {
		tmp = t_2 * t_0;
	} else {
		tmp = -(((((-0.16666666666666666 * Math.abs(im)) * Math.abs(re)) * Math.abs(re)) + Math.abs(im)) * 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.fabs(re) * math.fabs(re)) * math.fabs(im)) * -0.16666666666666666
	t_2 = math.sin(math.fabs(re))
	t_3 = (0.5 * t_2) * (math.exp(t_0) - math.exp(math.fabs(im)))
	tmp = 0
	if t_3 <= -math.inf:
		tmp = -1.0 * (math.fabs(re) * (((t_1 * t_1) - (math.fabs(im) * math.fabs(im))) / (t_1 - math.fabs(im))))
	elif t_3 <= 500000000.0:
		tmp = t_2 * t_0
	else:
		tmp = -(((((-0.16666666666666666 * math.fabs(im)) * math.fabs(re)) * math.fabs(re)) + math.fabs(im)) * 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 = Float64(Float64(Float64(abs(re) * abs(re)) * abs(im)) * -0.16666666666666666)
	t_2 = sin(abs(re))
	t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - exp(abs(im))))
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = Float64(-1.0 * Float64(abs(re) * Float64(Float64(Float64(t_1 * t_1) - Float64(abs(im) * abs(im))) / Float64(t_1 - abs(im)))));
	elseif (t_3 <= 500000000.0)
		tmp = Float64(t_2 * t_0);
	else
		tmp = Float64(-Float64(Float64(Float64(Float64(Float64(-0.16666666666666666 * abs(im)) * abs(re)) * abs(re)) + abs(im)) * 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 = ((abs(re) * abs(re)) * abs(im)) * -0.16666666666666666;
	t_2 = sin(abs(re));
	t_3 = (0.5 * t_2) * (exp(t_0) - exp(abs(im)));
	tmp = 0.0;
	if (t_3 <= -Inf)
		tmp = -1.0 * (abs(re) * (((t_1 * t_1) - (abs(im) * abs(im))) / (t_1 - abs(im))));
	elseif (t_3 <= 500000000.0)
		tmp = t_2 * t_0;
	else
		tmp = -(((((-0.16666666666666666 * abs(im)) * abs(re)) * abs(re)) + abs(im)) * 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[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -1/6), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(1/2 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(-1 * N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 500000000], N[(t$95$2 * t$95$0), $MachinePrecision], (-N[(N[(N[(N[(N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] + N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision])]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \left|im\right|\right) \cdot \frac{-1}{6}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(\frac{1}{2} \cdot t\_2\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\_3 \leq -\infty:\\
\;\;\;\;-1 \cdot \left(\left|re\right| \cdot \frac{t\_1 \cdot t\_1 - \left|im\right| \cdot \left|im\right|}{t\_1 - \left|im\right|}\right)\\

\mathbf{elif}\;t\_3 \leq 500000000:\\
\;\;\;\;t\_2 \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;-\left(\left(\left(\frac{-1}{6} \cdot \left|im\right|\right) \cdot \left|re\right|\right) \cdot \left|re\right| + \left|im\right|\right) \cdot \left|re\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))) < -inf.0

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) - im \cdot im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) - \color{blue}{im}}\right) \]
    9. Applied rewrites35.5%

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      15. lower-*.f6430.7%

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
    9. Applied rewrites30.7%

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

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

        \[\leadsto \mathsf{neg}\left(\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right)\right) \]
      3. lower-neg.f6430.7%

        \[\leadsto -\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      4. lift-134-z0z1z2z3z4N/A

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

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

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

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

        \[\leadsto -\left(\left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right) \cdot re - \left(\mathsf{neg}\left(im\right)\right)\right) \cdot re \]
      9. add-flip-revN/A

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

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

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

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

Alternative 4: 52.1% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      15. lower-*.f6430.7%

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
    9. Applied rewrites30.7%

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

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

        \[\leadsto \mathsf{neg}\left(\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right)\right) \]
      3. lower-neg.f6430.7%

        \[\leadsto -\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      4. lift-134-z0z1z2z3z4N/A

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

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

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

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

        \[\leadsto -\left(\left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right) \cdot re - \left(\mathsf{neg}\left(im\right)\right)\right) \cdot re \]
      9. add-flip-revN/A

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

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

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

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

    if -0.040000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 9.9999999999999994e-50

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \left(re \cdot \frac{\left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot \left(\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) - im \cdot im}{\frac{-1}{6} \cdot \left(im \cdot {re}^{2}\right) - \color{blue}{im}}\right) \]
    9. Applied rewrites35.5%

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 43.6% accurate, 1.3× speedup?

\[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{-5764607523034235}{576460752303423488}:\\ \;\;\;\;-\left(\left(\left(\frac{-1}{6} \cdot im\right) \cdot \left|re\right|\right) \cdot \left|re\right| + im\right) \cdot \left|re\right|\\ \mathbf{else}:\\ \;\;\;\;-\left|re\right| \cdot im\\ \end{array} \]
(FPCore (re im)
  :precision binary64
  (*
 (copysign 1 re)
 (if (<= (* 1/2 (sin (fabs re))) -5764607523034235/576460752303423488)
   (- (* (+ (* (* (* -1/6 im) (fabs re)) (fabs re)) im) (fabs re)))
   (- (* (fabs re) im)))))
double code(double re, double im) {
	double tmp;
	if ((0.5 * sin(fabs(re))) <= -0.01) {
		tmp = -(((((-0.16666666666666666 * im) * fabs(re)) * fabs(re)) + 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.01) {
		tmp = -(((((-0.16666666666666666 * im) * Math.abs(re)) * Math.abs(re)) + 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.01:
		tmp = -(((((-0.16666666666666666 * im) * math.fabs(re)) * math.fabs(re)) + 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.01)
		tmp = Float64(-Float64(Float64(Float64(Float64(Float64(-0.16666666666666666 * im) * abs(re)) * abs(re)) + 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.01)
		tmp = -(((((-0.16666666666666666 * im) * abs(re)) * abs(re)) + 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], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -5764607523034235/576460752303423488], (-N[(N[(N[(N[(N[(-1/6 * im), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $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}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{-5764607523034235}{576460752303423488}:\\
\;\;\;\;-\left(\left(\left(\frac{-1}{6} \cdot im\right) \cdot \left|re\right|\right) \cdot \left|re\right| + 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)) < -0.01

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      15. lower-*.f6430.7%

        \[\leadsto -1 \cdot \mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
    9. Applied rewrites30.7%

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

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

        \[\leadsto \mathsf{neg}\left(\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right)\right) \]
      3. lower-neg.f6430.7%

        \[\leadsto -\mathsf{134\_z0z1z2z3z4}\left(re, \left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right), re, im, -1\right) \]
      4. lift-134-z0z1z2z3z4N/A

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

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

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

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

        \[\leadsto -\left(\left(\left(\frac{-1}{6} \cdot im\right) \cdot re\right) \cdot re - \left(\mathsf{neg}\left(im\right)\right)\right) \cdot re \]
      9. add-flip-revN/A

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

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

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

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

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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 32.8% accurate, 39.5× 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 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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