math.sin on complex, imaginary part

Percentage Accurate: 54.2% → 99.9%
Time: 2.8s
Alternatives: 8
Speedup: 1.5×

Specification

?
\[\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (cos re)) (- (exp (- 0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - 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 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - 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 8 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: 54.2% accurate, 1.0× speedup?

\[\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (cos re)) (- (exp (- 0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - 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 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)

Alternative 1: 99.9% accurate, 1.5× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(e^{0 - im} - e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re} \]
    5. metadata-evalN/A

      \[\leadsto \left(\left(e^{0 - im} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \cos re \]
    6. mult-flip-revN/A

      \[\leadsto \color{blue}{\frac{e^{0 - im} - e^{im}}{2}} \cdot \cos re \]
    7. lift--.f64N/A

      \[\leadsto \frac{\color{blue}{e^{0 - im} - e^{im}}}{2} \cdot \cos re \]
    8. lift-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{0 - im}} - e^{im}}{2} \cdot \cos re \]
    9. lift-exp.f64N/A

      \[\leadsto \frac{e^{0 - im} - \color{blue}{e^{im}}}{2} \cdot \cos re \]
    10. --rgt-identityN/A

      \[\leadsto \frac{e^{0 - im} - e^{\color{blue}{im - 0}}}{2} \cdot \cos re \]
    11. sub-negate-revN/A

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

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

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

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

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

      \[\leadsto \sinh \color{blue}{\left(0 - im\right)} \cdot \cos re \]
    17. sub0-negN/A

      \[\leadsto \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)} \cdot \cos re \]
    18. lower-neg.f6499.9%

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

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

Alternative 2: 97.5% accurate, 0.4× speedup?

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

\mathbf{elif}\;t\_1 \leq \frac{4722366482869645}{4722366482869645213696}:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001

    1. Initial program 54.2%

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} - e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re} \]
      5. metadata-evalN/A

        \[\leadsto \left(\left(e^{0 - im} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \cos re \]
      6. mult-flip-revN/A

        \[\leadsto \color{blue}{\frac{e^{0 - im} - e^{im}}{2}} \cdot \cos re \]
      7. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{e^{0 - im} - e^{im}}}{2} \cdot \cos re \]
      8. lift-exp.f64N/A

        \[\leadsto \frac{\color{blue}{e^{0 - im}} - e^{im}}{2} \cdot \cos re \]
      9. lift-exp.f64N/A

        \[\leadsto \frac{e^{0 - im} - \color{blue}{e^{im}}}{2} \cdot \cos re \]
      10. --rgt-identityN/A

        \[\leadsto \frac{e^{0 - im} - e^{\color{blue}{im - 0}}}{2} \cdot \cos re \]
      11. sub-negate-revN/A

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

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

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

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

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

        \[\leadsto \sinh \color{blue}{\left(0 - im\right)} \cdot \cos re \]
      17. sub0-negN/A

        \[\leadsto \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)} \cdot \cos re \]
      18. lower-neg.f6499.9%

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

      \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \cos re} \]
    4. Taylor expanded in re around 0

      \[\leadsto \sinh \left(-im\right) \cdot \color{blue}{1} \]
    5. Step-by-step derivation
      1. Applied rewrites64.9%

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

      if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 9.9999999999999995e-7

      1. Initial program 54.2%

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

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

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

          \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
        3. lower-cos.f6452.2%

          \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
      4. Applied rewrites52.2%

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

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

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

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

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

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

          \[\leadsto \left(\mathsf{neg}\left(\cos re\right)\right) \cdot \color{blue}{im} \]
        7. lower-neg.f6452.2%

          \[\leadsto \left(-\cos re\right) \cdot im \]
      6. Applied rewrites52.2%

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

      if 9.9999999999999995e-7 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

      1. Initial program 54.2%

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

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

          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
      4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \color{blue}{{re}^{2}} - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
        14. lower-unsound--.f6430.2%

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

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

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

          \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
      9. Applied rewrites30.2%

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

        \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot im\right) \]
      11. Step-by-step derivation
        1. Applied rewrites37.5%

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

      Alternative 3: 85.5% accurate, 0.4× speedup?

      \[\begin{array}{l} t_0 := \frac{-1}{4} \cdot \left(re \cdot re\right)\\ t_1 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\ \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -50:\\ \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\ \mathbf{elif}\;t\_1 \leq \frac{4722366482869645}{4722366482869645213696}:\\ \;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 \cdot t\_0 - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot \left|im\right|\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
        :precision binary64
        (let* ((t_0 (* -1/4 (* re re)))
             (t_1
              (*
               (* 1/2 (cos re))
               (- (exp (- 0 (fabs im))) (exp (fabs im))))))
        (*
         (copysign 1 im)
         (if (<= t_1 -50)
           (*
            1/2
            (-
             (+
              1
              (* (fabs im) (- (* (fabs im) (+ 1/2 (* -1/6 (fabs im)))) 1)))
             (+ 1 (fabs im))))
           (if (<= t_1 4722366482869645/4722366482869645213696)
             (* (- (cos re)) (fabs im))
             (* (/ (- (* t_0 t_0) (* 1/2 1/2)) -1/2) (* -2 (fabs im))))))))
      double code(double re, double im) {
      	double t_0 = -0.25 * (re * re);
      	double t_1 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
      	double tmp;
      	if (t_1 <= -50.0) {
      		tmp = 0.5 * ((1.0 + (fabs(im) * ((fabs(im) * (0.5 + (-0.16666666666666666 * fabs(im)))) - 1.0))) - (1.0 + fabs(im)));
      	} else if (t_1 <= 1e-6) {
      		tmp = -cos(re) * fabs(im);
      	} else {
      		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * fabs(im));
      	}
      	return copysign(1.0, im) * tmp;
      }
      
      public static double code(double re, double im) {
      	double t_0 = -0.25 * (re * re);
      	double t_1 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
      	double tmp;
      	if (t_1 <= -50.0) {
      		tmp = 0.5 * ((1.0 + (Math.abs(im) * ((Math.abs(im) * (0.5 + (-0.16666666666666666 * Math.abs(im)))) - 1.0))) - (1.0 + Math.abs(im)));
      	} else if (t_1 <= 1e-6) {
      		tmp = -Math.cos(re) * Math.abs(im);
      	} else {
      		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * Math.abs(im));
      	}
      	return Math.copySign(1.0, im) * tmp;
      }
      
      def code(re, im):
      	t_0 = -0.25 * (re * re)
      	t_1 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))
      	tmp = 0
      	if t_1 <= -50.0:
      		tmp = 0.5 * ((1.0 + (math.fabs(im) * ((math.fabs(im) * (0.5 + (-0.16666666666666666 * math.fabs(im)))) - 1.0))) - (1.0 + math.fabs(im)))
      	elif t_1 <= 1e-6:
      		tmp = -math.cos(re) * math.fabs(im)
      	else:
      		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * math.fabs(im))
      	return math.copysign(1.0, im) * tmp
      
      function code(re, im)
      	t_0 = Float64(-0.25 * Float64(re * re))
      	t_1 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im))))
      	tmp = 0.0
      	if (t_1 <= -50.0)
      		tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(abs(im) * Float64(Float64(abs(im) * Float64(0.5 + Float64(-0.16666666666666666 * abs(im)))) - 1.0))) - Float64(1.0 + abs(im))));
      	elseif (t_1 <= 1e-6)
      		tmp = Float64(Float64(-cos(re)) * abs(im));
      	else
      		tmp = Float64(Float64(Float64(Float64(t_0 * t_0) - Float64(0.5 * 0.5)) / -0.5) * Float64(-2.0 * abs(im)));
      	end
      	return Float64(copysign(1.0, im) * tmp)
      end
      
      function tmp_2 = code(re, im)
      	t_0 = -0.25 * (re * re);
      	t_1 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)));
      	tmp = 0.0;
      	if (t_1 <= -50.0)
      		tmp = 0.5 * ((1.0 + (abs(im) * ((abs(im) * (0.5 + (-0.16666666666666666 * abs(im)))) - 1.0))) - (1.0 + abs(im)));
      	elseif (t_1 <= 1e-6)
      		tmp = -cos(re) * abs(im);
      	else
      		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * abs(im));
      	end
      	tmp_2 = (sign(im) * abs(1.0)) * tmp;
      end
      
      code[re_, im_] := Block[{t$95$0 = N[(-1/4 * N[(re * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -50], N[(1/2 * N[(N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[im], $MachinePrecision] * N[(1/2 + N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1 + N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4722366482869645/4722366482869645213696], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(1/2 * 1/2), $MachinePrecision]), $MachinePrecision] / -1/2), $MachinePrecision] * N[(-2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
      
      \begin{array}{l}
      t_0 := \frac{-1}{4} \cdot \left(re \cdot re\right)\\
      t_1 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
      \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
      \mathbf{if}\;t\_1 \leq -50:\\
      \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\
      
      \mathbf{elif}\;t\_1 \leq \frac{4722366482869645}{4722366482869645213696}:\\
      \;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{t\_0 \cdot t\_0 - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot \left|im\right|\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -50

        1. Initial program 54.2%

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

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

            \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(0 - im\right) + 0}} - e^{im}\right) \]
          3. metadata-evalN/A

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

            \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(\left(0 - im\right) + 1\right) - 1}} - e^{im}\right) \]
          5. exp-diffN/A

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

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

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

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

            \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\color{blue}{\left(0 - im\right)} + 1}}{e^{1}} - e^{im}\right) \]
          10. sub0-negN/A

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

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

            \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\left(-im\right) + 1}}{\color{blue}{\mathsf{E}\left(\right)}} - e^{im}\right) \]
          13. lower-E.f6454.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(\left(1 + im \cdot \left(im \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot im\right) - 1\right)\right) - \left(1 + im\right)\right) \]
        11. Step-by-step derivation
          1. Applied rewrites28.5%

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

          if -50 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 9.9999999999999995e-7

          1. Initial program 54.2%

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

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

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

              \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
            3. lower-cos.f6452.2%

              \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
          4. Applied rewrites52.2%

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

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

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

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

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

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

              \[\leadsto \left(\mathsf{neg}\left(\cos re\right)\right) \cdot \color{blue}{im} \]
            7. lower-neg.f6452.2%

              \[\leadsto \left(-\cos re\right) \cdot im \]
          6. Applied rewrites52.2%

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

          if 9.9999999999999995e-7 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

          1. Initial program 54.2%

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

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

              \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
          4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \color{blue}{{re}^{2}} - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
            14. lower-unsound--.f6430.2%

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

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

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

              \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
          9. Applied rewrites30.2%

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

            \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot im\right) \]
          11. Step-by-step derivation
            1. Applied rewrites37.5%

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

          Alternative 4: 63.8% accurate, 0.4× speedup?

          \[\begin{array}{l} t_0 := \frac{-1}{4} \cdot \left(re \cdot re\right)\\ t_1 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\ \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq \frac{-5764607523034235}{288230376151711744}:\\ \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;-\left|im\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 \cdot t\_0 - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot \left|im\right|\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
            :precision binary64
            (let* ((t_0 (* -1/4 (* re re)))
                 (t_1
                  (*
                   (* 1/2 (cos re))
                   (- (exp (- 0 (fabs im))) (exp (fabs im))))))
            (*
             (copysign 1 im)
             (if (<= t_1 -5764607523034235/288230376151711744)
               (*
                1/2
                (-
                 (+
                  1
                  (* (fabs im) (- (* (fabs im) (+ 1/2 (* -1/6 (fabs im)))) 1)))
                 (+ 1 (fabs im))))
               (if (<= t_1 0)
                 (- (fabs im))
                 (* (/ (- (* t_0 t_0) (* 1/2 1/2)) -1/2) (* -2 (fabs im))))))))
          double code(double re, double im) {
          	double t_0 = -0.25 * (re * re);
          	double t_1 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
          	double tmp;
          	if (t_1 <= -0.02) {
          		tmp = 0.5 * ((1.0 + (fabs(im) * ((fabs(im) * (0.5 + (-0.16666666666666666 * fabs(im)))) - 1.0))) - (1.0 + fabs(im)));
          	} else if (t_1 <= 0.0) {
          		tmp = -fabs(im);
          	} else {
          		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * fabs(im));
          	}
          	return copysign(1.0, im) * tmp;
          }
          
          public static double code(double re, double im) {
          	double t_0 = -0.25 * (re * re);
          	double t_1 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
          	double tmp;
          	if (t_1 <= -0.02) {
          		tmp = 0.5 * ((1.0 + (Math.abs(im) * ((Math.abs(im) * (0.5 + (-0.16666666666666666 * Math.abs(im)))) - 1.0))) - (1.0 + Math.abs(im)));
          	} else if (t_1 <= 0.0) {
          		tmp = -Math.abs(im);
          	} else {
          		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * Math.abs(im));
          	}
          	return Math.copySign(1.0, im) * tmp;
          }
          
          def code(re, im):
          	t_0 = -0.25 * (re * re)
          	t_1 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))
          	tmp = 0
          	if t_1 <= -0.02:
          		tmp = 0.5 * ((1.0 + (math.fabs(im) * ((math.fabs(im) * (0.5 + (-0.16666666666666666 * math.fabs(im)))) - 1.0))) - (1.0 + math.fabs(im)))
          	elif t_1 <= 0.0:
          		tmp = -math.fabs(im)
          	else:
          		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * math.fabs(im))
          	return math.copysign(1.0, im) * tmp
          
          function code(re, im)
          	t_0 = Float64(-0.25 * Float64(re * re))
          	t_1 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im))))
          	tmp = 0.0
          	if (t_1 <= -0.02)
          		tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(abs(im) * Float64(Float64(abs(im) * Float64(0.5 + Float64(-0.16666666666666666 * abs(im)))) - 1.0))) - Float64(1.0 + abs(im))));
          	elseif (t_1 <= 0.0)
          		tmp = Float64(-abs(im));
          	else
          		tmp = Float64(Float64(Float64(Float64(t_0 * t_0) - Float64(0.5 * 0.5)) / -0.5) * Float64(-2.0 * abs(im)));
          	end
          	return Float64(copysign(1.0, im) * tmp)
          end
          
          function tmp_2 = code(re, im)
          	t_0 = -0.25 * (re * re);
          	t_1 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)));
          	tmp = 0.0;
          	if (t_1 <= -0.02)
          		tmp = 0.5 * ((1.0 + (abs(im) * ((abs(im) * (0.5 + (-0.16666666666666666 * abs(im)))) - 1.0))) - (1.0 + abs(im)));
          	elseif (t_1 <= 0.0)
          		tmp = -abs(im);
          	else
          		tmp = (((t_0 * t_0) - (0.5 * 0.5)) / -0.5) * (-2.0 * abs(im));
          	end
          	tmp_2 = (sign(im) * abs(1.0)) * tmp;
          end
          
          code[re_, im_] := Block[{t$95$0 = N[(-1/4 * N[(re * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -5764607523034235/288230376151711744], N[(1/2 * N[(N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[im], $MachinePrecision] * N[(1/2 + N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1 + N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0], (-N[Abs[im], $MachinePrecision]), N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(1/2 * 1/2), $MachinePrecision]), $MachinePrecision] / -1/2), $MachinePrecision] * N[(-2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
          
          \begin{array}{l}
          t_0 := \frac{-1}{4} \cdot \left(re \cdot re\right)\\
          t_1 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
          \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
          \mathbf{if}\;t\_1 \leq \frac{-5764607523034235}{288230376151711744}:\\
          \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\
          
          \mathbf{elif}\;t\_1 \leq 0:\\
          \;\;\;\;-\left|im\right|\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{t\_0 \cdot t\_0 - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot \left|im\right|\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.02

            1. Initial program 54.2%

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(0 - im\right) + 0}} - e^{im}\right) \]
              3. metadata-evalN/A

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

                \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(\left(0 - im\right) + 1\right) - 1}} - e^{im}\right) \]
              5. exp-diffN/A

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

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\color{blue}{\left(0 - im\right)} + 1}}{e^{1}} - e^{im}\right) \]
              10. sub0-negN/A

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\left(-im\right) + 1}}{\color{blue}{\mathsf{E}\left(\right)}} - e^{im}\right) \]
              13. lower-E.f6454.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(\left(1 + im \cdot \left(im \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot im\right) - 1\right)\right) - \left(1 + im\right)\right) \]
            11. Step-by-step derivation
              1. Applied rewrites28.5%

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

              if -0.02 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0

              1. Initial program 54.2%

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

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

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

                  \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
                3. lower-cos.f6452.2%

                  \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
              4. Applied rewrites52.2%

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

                \[\leadsto -1 \cdot im \]
              6. Step-by-step derivation
                1. Applied rewrites29.8%

                  \[\leadsto -1 \cdot im \]
                2. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto -1 \cdot \color{blue}{im} \]
                  2. mul-1-negN/A

                    \[\leadsto \mathsf{neg}\left(im\right) \]
                  3. lower-neg.f6429.8%

                    \[\leadsto -im \]
                3. Applied rewrites29.8%

                  \[\leadsto -im \]

                if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                1. Initial program 54.2%

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

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

                    \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
                4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \color{blue}{{re}^{2}} - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
                  14. lower-unsound--.f6430.2%

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

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

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

                    \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{1}{2}} \cdot \left(-2 \cdot im\right) \]
                9. Applied rewrites30.2%

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

                  \[\leadsto \frac{\left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right)\right) - \frac{1}{2} \cdot \frac{1}{2}}{\frac{-1}{2}} \cdot \left(-2 \cdot im\right) \]
                11. Step-by-step derivation
                  1. Applied rewrites37.5%

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

                Alternative 5: 63.0% accurate, 0.4× speedup?

                \[\begin{array}{l} t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\ \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq \frac{-5764607523034235}{288230376151711744}:\\ \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-\left|im\right|\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot \left(-2 \cdot \left|im\right|\right)\\ \end{array} \end{array} \]
                (FPCore (re im)
                  :precision binary64
                  (let* ((t_0
                        (*
                         (* 1/2 (cos re))
                         (- (exp (- 0 (fabs im))) (exp (fabs im))))))
                  (*
                   (copysign 1 im)
                   (if (<= t_0 -5764607523034235/288230376151711744)
                     (*
                      1/2
                      (-
                       (+
                        1
                        (* (fabs im) (- (* (fabs im) (+ 1/2 (* -1/6 (fabs im)))) 1)))
                       (+ 1 (fabs im))))
                     (if (<= t_0 0)
                       (- (fabs im))
                       (*
                        (+ 1/2 (* -1/4 (sqrt (* (* re re) (* re re)))))
                        (* -2 (fabs im))))))))
                double code(double re, double im) {
                	double t_0 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
                	double tmp;
                	if (t_0 <= -0.02) {
                		tmp = 0.5 * ((1.0 + (fabs(im) * ((fabs(im) * (0.5 + (-0.16666666666666666 * fabs(im)))) - 1.0))) - (1.0 + fabs(im)));
                	} else if (t_0 <= 0.0) {
                		tmp = -fabs(im);
                	} else {
                		tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * (-2.0 * fabs(im));
                	}
                	return copysign(1.0, im) * tmp;
                }
                
                public static double code(double re, double im) {
                	double t_0 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
                	double tmp;
                	if (t_0 <= -0.02) {
                		tmp = 0.5 * ((1.0 + (Math.abs(im) * ((Math.abs(im) * (0.5 + (-0.16666666666666666 * Math.abs(im)))) - 1.0))) - (1.0 + Math.abs(im)));
                	} else if (t_0 <= 0.0) {
                		tmp = -Math.abs(im);
                	} else {
                		tmp = (0.5 + (-0.25 * Math.sqrt(((re * re) * (re * re))))) * (-2.0 * Math.abs(im));
                	}
                	return Math.copySign(1.0, im) * tmp;
                }
                
                def code(re, im):
                	t_0 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))
                	tmp = 0
                	if t_0 <= -0.02:
                		tmp = 0.5 * ((1.0 + (math.fabs(im) * ((math.fabs(im) * (0.5 + (-0.16666666666666666 * math.fabs(im)))) - 1.0))) - (1.0 + math.fabs(im)))
                	elif t_0 <= 0.0:
                		tmp = -math.fabs(im)
                	else:
                		tmp = (0.5 + (-0.25 * math.sqrt(((re * re) * (re * re))))) * (-2.0 * math.fabs(im))
                	return math.copysign(1.0, im) * tmp
                
                function code(re, im)
                	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im))))
                	tmp = 0.0
                	if (t_0 <= -0.02)
                		tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(abs(im) * Float64(Float64(abs(im) * Float64(0.5 + Float64(-0.16666666666666666 * abs(im)))) - 1.0))) - Float64(1.0 + abs(im))));
                	elseif (t_0 <= 0.0)
                		tmp = Float64(-abs(im));
                	else
                		tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(Float64(Float64(re * re) * Float64(re * re))))) * Float64(-2.0 * abs(im)));
                	end
                	return Float64(copysign(1.0, im) * tmp)
                end
                
                function tmp_2 = code(re, im)
                	t_0 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)));
                	tmp = 0.0;
                	if (t_0 <= -0.02)
                		tmp = 0.5 * ((1.0 + (abs(im) * ((abs(im) * (0.5 + (-0.16666666666666666 * abs(im)))) - 1.0))) - (1.0 + abs(im)));
                	elseif (t_0 <= 0.0)
                		tmp = -abs(im);
                	else
                		tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * (-2.0 * abs(im));
                	end
                	tmp_2 = (sign(im) * abs(1.0)) * tmp;
                end
                
                code[re_, im_] := Block[{t$95$0 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, -5764607523034235/288230376151711744], N[(1/2 * N[(N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[im], $MachinePrecision] * N[(1/2 + N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1 + N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0], (-N[Abs[im], $MachinePrecision]), N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
                
                \begin{array}{l}
                t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
                \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
                \mathbf{if}\;t\_0 \leq \frac{-5764607523034235}{288230376151711744}:\\
                \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\
                
                \mathbf{elif}\;t\_0 \leq 0:\\
                \;\;\;\;-\left|im\right|\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot \left(-2 \cdot \left|im\right|\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.02

                  1. Initial program 54.2%

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

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

                      \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(0 - im\right) + 0}} - e^{im}\right) \]
                    3. metadata-evalN/A

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

                      \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(\left(0 - im\right) + 1\right) - 1}} - e^{im}\right) \]
                    5. exp-diffN/A

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

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

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

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

                      \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\color{blue}{\left(0 - im\right)} + 1}}{e^{1}} - e^{im}\right) \]
                    10. sub0-negN/A

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

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

                      \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\left(-im\right) + 1}}{\color{blue}{\mathsf{E}\left(\right)}} - e^{im}\right) \]
                    13. lower-E.f6454.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(\left(1 + im \cdot \left(im \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot im\right) - 1\right)\right) - \left(1 + im\right)\right) \]
                  11. Step-by-step derivation
                    1. Applied rewrites28.5%

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

                    if -0.02 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0

                    1. Initial program 54.2%

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

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

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

                        \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
                      3. lower-cos.f6452.2%

                        \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
                    4. Applied rewrites52.2%

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

                      \[\leadsto -1 \cdot im \]
                    6. Step-by-step derivation
                      1. Applied rewrites29.8%

                        \[\leadsto -1 \cdot im \]
                      2. Step-by-step derivation
                        1. lift-*.f64N/A

                          \[\leadsto -1 \cdot \color{blue}{im} \]
                        2. mul-1-negN/A

                          \[\leadsto \mathsf{neg}\left(im\right) \]
                        3. lower-neg.f6429.8%

                          \[\leadsto -im \]
                      3. Applied rewrites29.8%

                        \[\leadsto -im \]

                      if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                      1. Initial program 54.2%

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

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

                          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
                      4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot \left(-2 \cdot im\right) \]
                        10. lower-*.f6436.9%

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

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

                    Alternative 6: 62.5% accurate, 0.4× speedup?

                    \[\begin{array}{l} t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\ \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq \frac{-5764607523034235}{288230376151711744}:\\ \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-\left|im\right|\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \left|im\right|\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{-1}{2}\right)\\ \end{array} \end{array} \]
                    (FPCore (re im)
                      :precision binary64
                      (let* ((t_0
                            (*
                             (* 1/2 (cos re))
                             (- (exp (- 0 (fabs im))) (exp (fabs im))))))
                      (*
                       (copysign 1 im)
                       (if (<= t_0 -5764607523034235/288230376151711744)
                         (*
                          1/2
                          (-
                           (+
                            1
                            (* (fabs im) (- (* (fabs im) (+ 1/2 (* -1/6 (fabs im)))) 1)))
                           (+ 1 (fabs im))))
                         (if (<= t_0 0)
                           (- (fabs im))
                           (* (* -2 (fabs im)) (- (* -1/4 (* re re)) -1/2)))))))
                    double code(double re, double im) {
                    	double t_0 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
                    	double tmp;
                    	if (t_0 <= -0.02) {
                    		tmp = 0.5 * ((1.0 + (fabs(im) * ((fabs(im) * (0.5 + (-0.16666666666666666 * fabs(im)))) - 1.0))) - (1.0 + fabs(im)));
                    	} else if (t_0 <= 0.0) {
                    		tmp = -fabs(im);
                    	} else {
                    		tmp = (-2.0 * fabs(im)) * ((-0.25 * (re * re)) - -0.5);
                    	}
                    	return copysign(1.0, im) * tmp;
                    }
                    
                    public static double code(double re, double im) {
                    	double t_0 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
                    	double tmp;
                    	if (t_0 <= -0.02) {
                    		tmp = 0.5 * ((1.0 + (Math.abs(im) * ((Math.abs(im) * (0.5 + (-0.16666666666666666 * Math.abs(im)))) - 1.0))) - (1.0 + Math.abs(im)));
                    	} else if (t_0 <= 0.0) {
                    		tmp = -Math.abs(im);
                    	} else {
                    		tmp = (-2.0 * Math.abs(im)) * ((-0.25 * (re * re)) - -0.5);
                    	}
                    	return Math.copySign(1.0, im) * tmp;
                    }
                    
                    def code(re, im):
                    	t_0 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))
                    	tmp = 0
                    	if t_0 <= -0.02:
                    		tmp = 0.5 * ((1.0 + (math.fabs(im) * ((math.fabs(im) * (0.5 + (-0.16666666666666666 * math.fabs(im)))) - 1.0))) - (1.0 + math.fabs(im)))
                    	elif t_0 <= 0.0:
                    		tmp = -math.fabs(im)
                    	else:
                    		tmp = (-2.0 * math.fabs(im)) * ((-0.25 * (re * re)) - -0.5)
                    	return math.copysign(1.0, im) * tmp
                    
                    function code(re, im)
                    	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im))))
                    	tmp = 0.0
                    	if (t_0 <= -0.02)
                    		tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(abs(im) * Float64(Float64(abs(im) * Float64(0.5 + Float64(-0.16666666666666666 * abs(im)))) - 1.0))) - Float64(1.0 + abs(im))));
                    	elseif (t_0 <= 0.0)
                    		tmp = Float64(-abs(im));
                    	else
                    		tmp = Float64(Float64(-2.0 * abs(im)) * Float64(Float64(-0.25 * Float64(re * re)) - -0.5));
                    	end
                    	return Float64(copysign(1.0, im) * tmp)
                    end
                    
                    function tmp_2 = code(re, im)
                    	t_0 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)));
                    	tmp = 0.0;
                    	if (t_0 <= -0.02)
                    		tmp = 0.5 * ((1.0 + (abs(im) * ((abs(im) * (0.5 + (-0.16666666666666666 * abs(im)))) - 1.0))) - (1.0 + abs(im)));
                    	elseif (t_0 <= 0.0)
                    		tmp = -abs(im);
                    	else
                    		tmp = (-2.0 * abs(im)) * ((-0.25 * (re * re)) - -0.5);
                    	end
                    	tmp_2 = (sign(im) * abs(1.0)) * tmp;
                    end
                    
                    code[re_, im_] := Block[{t$95$0 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, -5764607523034235/288230376151711744], N[(1/2 * N[(N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[im], $MachinePrecision] * N[(1/2 + N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1 + N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0], (-N[Abs[im], $MachinePrecision]), N[(N[(-2 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[(N[(-1/4 * N[(re * re), $MachinePrecision]), $MachinePrecision] - -1/2), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
                    \mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
                    \mathbf{if}\;t\_0 \leq \frac{-5764607523034235}{288230376151711744}:\\
                    \;\;\;\;\frac{1}{2} \cdot \left(\left(1 + \left|im\right| \cdot \left(\left|im\right| \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \left|im\right|\right) - 1\right)\right) - \left(1 + \left|im\right|\right)\right)\\
                    
                    \mathbf{elif}\;t\_0 \leq 0:\\
                    \;\;\;\;-\left|im\right|\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(-2 \cdot \left|im\right|\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{-1}{2}\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.02

                      1. Initial program 54.2%

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

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

                          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(0 - im\right) + 0}} - e^{im}\right) \]
                        3. metadata-evalN/A

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

                          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{\color{blue}{\left(\left(0 - im\right) + 1\right) - 1}} - e^{im}\right) \]
                        5. exp-diffN/A

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

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

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

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

                          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\color{blue}{\left(0 - im\right)} + 1}}{e^{1}} - e^{im}\right) \]
                        10. sub0-negN/A

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

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

                          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\frac{e^{\left(-im\right) + 1}}{\color{blue}{\mathsf{E}\left(\right)}} - e^{im}\right) \]
                        13. lower-E.f6454.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(\left(1 + im \cdot \left(im \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot im\right) - 1\right)\right) - \left(1 + im\right)\right) \]
                      11. Step-by-step derivation
                        1. Applied rewrites28.5%

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

                        if -0.02 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0

                        1. Initial program 54.2%

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

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

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

                            \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
                          3. lower-cos.f6452.2%

                            \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
                        4. Applied rewrites52.2%

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

                          \[\leadsto -1 \cdot im \]
                        6. Step-by-step derivation
                          1. Applied rewrites29.8%

                            \[\leadsto -1 \cdot im \]
                          2. Step-by-step derivation
                            1. lift-*.f64N/A

                              \[\leadsto -1 \cdot \color{blue}{im} \]
                            2. mul-1-negN/A

                              \[\leadsto \mathsf{neg}\left(im\right) \]
                            3. lower-neg.f6429.8%

                              \[\leadsto -im \]
                          3. Applied rewrites29.8%

                            \[\leadsto -im \]

                          if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                          1. Initial program 54.2%

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

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

                              \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
                          4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \left(-2 \cdot im\right) \cdot \left(\frac{-1}{4} \cdot {re}^{2} - \frac{-1}{2}\right) \]
                            8. metadata-evalN/A

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

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

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

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

                              \[\leadsto \left(-2 \cdot im\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{1}{-2}\right) \]
                            13. metadata-eval36.4%

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

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

                        Alternative 7: 39.4% accurate, 0.7× speedup?

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

                          1. Initial program 54.2%

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

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

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

                              \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
                            3. lower-cos.f6452.2%

                              \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
                          4. Applied rewrites52.2%

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

                            \[\leadsto -1 \cdot im \]
                          6. Step-by-step derivation
                            1. Applied rewrites29.8%

                              \[\leadsto -1 \cdot im \]
                            2. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto -1 \cdot \color{blue}{im} \]
                              2. mul-1-negN/A

                                \[\leadsto \mathsf{neg}\left(im\right) \]
                              3. lower-neg.f6429.8%

                                \[\leadsto -im \]
                            3. Applied rewrites29.8%

                              \[\leadsto -im \]

                            if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                            1. Initial program 54.2%

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

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

                                \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(-2 \cdot \color{blue}{im}\right) \]
                            4. Applied rewrites52.2%

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(-2 \cdot im\right) \cdot \left(\frac{-1}{4} \cdot {re}^{2} - \frac{-1}{2}\right) \]
                              8. metadata-evalN/A

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

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

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

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

                                \[\leadsto \left(-2 \cdot im\right) \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{1}{-2}\right) \]
                              13. metadata-eval36.4%

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

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

                          Alternative 8: 29.8% accurate, 105.7× speedup?

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

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

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

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

                              \[\leadsto -1 \cdot \left(im \cdot \color{blue}{\cos re}\right) \]
                            3. lower-cos.f6452.2%

                              \[\leadsto -1 \cdot \left(im \cdot \cos re\right) \]
                          4. Applied rewrites52.2%

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

                            \[\leadsto -1 \cdot im \]
                          6. Step-by-step derivation
                            1. Applied rewrites29.8%

                              \[\leadsto -1 \cdot im \]
                            2. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto -1 \cdot \color{blue}{im} \]
                              2. mul-1-negN/A

                                \[\leadsto \mathsf{neg}\left(im\right) \]
                              3. lower-neg.f6429.8%

                                \[\leadsto -im \]
                            3. Applied rewrites29.8%

                              \[\leadsto -im \]
                            4. Add Preprocessing

                            Reproduce

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