math.sin on complex, imaginary part

Percentage Accurate: 53.1% → 99.9%
Time: 5.1s
Alternatives: 12
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.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[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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 12 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: 53.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.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[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \left(\cos re \cdot \left(-2 \cdot \sinh im\right)\right) \cdot 0.5 \end{array} \]
(FPCore (re im) :precision binary64 (* (* (cos re) (* -2.0 (sinh im))) 0.5))
double code(double re, double im) {
	return (cos(re) * (-2.0 * sinh(im))) * 0.5;
}
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 = (cos(re) * ((-2.0d0) * sinh(im))) * 0.5d0
end function
public static double code(double re, double im) {
	return (Math.cos(re) * (-2.0 * Math.sinh(im))) * 0.5;
}
def code(re, im):
	return (math.cos(re) * (-2.0 * math.sinh(im))) * 0.5
function code(re, im)
	return Float64(Float64(cos(re) * Float64(-2.0 * sinh(im))) * 0.5)
end
function tmp = code(re, im)
	tmp = (cos(re) * (-2.0 * sinh(im))) * 0.5;
end
code[re_, im_] := N[(N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\cos re \cdot \left(-2 \cdot \sinh im\right)\right) \cdot 0.5
\end{array}
Derivation
  1. Initial program 53.1%

    \[\left(0.5 \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. lift-cos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \cos re\right) \cdot \frac{1}{2} \]
    19. lift-cos.f6499.9

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\cos re \cdot \color{blue}{\left(-2 \cdot \sinh im\right)}\right) \cdot \frac{1}{2} \]
    12. lift-sinh.f6499.9

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

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

Alternative 2: 92.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -100:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
   (if (<= t_0 -100.0)
     (* (* -2.0 (sinh im)) 0.5)
     (if (<= t_0 0.0)
       (* (* (cos re) (fma -0.16666666666666666 (* im im) -1.0)) im)
       (* (- (cosh im) (fma 2.0 im 1.0)) 0.5)))))
double code(double re, double im) {
	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	double tmp;
	if (t_0 <= -100.0) {
		tmp = (-2.0 * sinh(im)) * 0.5;
	} else if (t_0 <= 0.0) {
		tmp = (cos(re) * fma(-0.16666666666666666, (im * im), -1.0)) * im;
	} else {
		tmp = (cosh(im) - fma(2.0, im, 1.0)) * 0.5;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
	tmp = 0.0
	if (t_0 <= -100.0)
		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(cos(re) * fma(-0.16666666666666666, Float64(im * im), -1.0)) * im);
	else
		tmp = Float64(Float64(cosh(im) - fma(2.0, im, 1.0)) * 0.5);
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[Cos[re], $MachinePrecision] * N[(-0.16666666666666666 * N[(im * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision], N[(N[(N[Cosh[im], $MachinePrecision] - N[(2.0 * im + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im\\

\mathbf{else}:\\
\;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\


\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))) < -100

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
    3. Step-by-step derivation
      1. Applied rewrites74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \frac{1}{2} \]
        14. lift-sinh.f6474.3

          \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot 0.5 \]
      3. Applied rewrites74.3%

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

      if -100 < (*.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 6.8%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im \]
      4. Applied rewrites99.6%

        \[\leadsto \color{blue}{\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot 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 97.7%

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

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
        3. negate-sub2N/A

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

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

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

          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
        7. lower-sinh.f6473.2

          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
      4. Applied rewrites73.2%

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
      5. Step-by-step derivation
        1. lift-neg.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
        3. lift-sinh.f64N/A

          \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
        4. sinh-undef-revN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
        5. negate-sub2N/A

          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
        6. negate-subN/A

          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
        7. sinh---cosh-revN/A

          \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
        8. associate--r-N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
        9. lift-cosh.f64N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
        10. lift-sinh.f64N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
        11. lift-neg.f64N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
        12. lift-exp.f64N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
        13. lift--.f64N/A

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
        14. lift--.f6472.0

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
      6. Applied rewrites72.0%

        \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
      7. Taylor expanded in im around 0

        \[\leadsto \left(\cosh im - \left(1 + 2 \cdot im\right)\right) \cdot \frac{1}{2} \]
      8. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \left(\cosh im - \left(2 \cdot im + 1\right)\right) \cdot \frac{1}{2} \]
        2. lower-fma.f6495.1

          \[\leadsto \left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5 \]
      9. Applied rewrites95.1%

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

    Alternative 3: 92.2% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -100:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\left(\cos re \cdot im\right) \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
       (if (<= t_0 -100.0)
         (* (* -2.0 (sinh im)) 0.5)
         (if (<= t_0 0.0)
           (* (* (cos re) im) (fma (* im im) -0.16666666666666666 -1.0))
           (* (- (cosh im) (fma 2.0 im 1.0)) 0.5)))))
    double code(double re, double im) {
    	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
    	double tmp;
    	if (t_0 <= -100.0) {
    		tmp = (-2.0 * sinh(im)) * 0.5;
    	} else if (t_0 <= 0.0) {
    		tmp = (cos(re) * im) * fma((im * im), -0.16666666666666666, -1.0);
    	} else {
    		tmp = (cosh(im) - fma(2.0, im, 1.0)) * 0.5;
    	}
    	return tmp;
    }
    
    function code(re, im)
    	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
    	tmp = 0.0
    	if (t_0 <= -100.0)
    		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
    	elseif (t_0 <= 0.0)
    		tmp = Float64(Float64(cos(re) * im) * fma(Float64(im * im), -0.16666666666666666, -1.0));
    	else
    		tmp = Float64(Float64(cosh(im) - fma(2.0, im, 1.0)) * 0.5);
    	end
    	return tmp
    end
    
    code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cosh[im], $MachinePrecision] - N[(2.0 * im + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
    \mathbf{if}\;t\_0 \leq -100:\\
    \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
    
    \mathbf{elif}\;t\_0 \leq 0:\\
    \;\;\;\;\left(\cos re \cdot im\right) \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\
    
    
    \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))) < -100

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. Step-by-step derivation
        1. Applied rewrites74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \frac{1}{2} \]
          14. lift-sinh.f6474.3

            \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot 0.5 \]
        3. Applied rewrites74.3%

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

        if -100 < (*.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 6.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im \]
        4. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\cos re \cdot im\right) \cdot \mathsf{fma}\left(im \cdot im, \frac{-1}{6}, -1\right) \]
          20. lift-*.f6499.6

            \[\leadsto \left(\cos re \cdot im\right) \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \]
        6. Applied rewrites99.6%

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

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

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

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
        3. Step-by-step derivation
          1. *-commutativeN/A

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

            \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
          3. negate-sub2N/A

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

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

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

            \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
          7. lower-sinh.f6473.2

            \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
        4. Applied rewrites73.2%

          \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
        5. Step-by-step derivation
          1. lift-neg.f64N/A

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

            \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
          3. lift-sinh.f64N/A

            \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
          4. sinh-undef-revN/A

            \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
          5. negate-sub2N/A

            \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
          6. negate-subN/A

            \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
          7. sinh---cosh-revN/A

            \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
          8. associate--r-N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
          9. lift-cosh.f64N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
          10. lift-sinh.f64N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
          11. lift-neg.f64N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
          12. lift-exp.f64N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
          13. lift--.f64N/A

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
          14. lift--.f6472.0

            \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
        6. Applied rewrites72.0%

          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
        7. Taylor expanded in im around 0

          \[\leadsto \left(\cosh im - \left(1 + 2 \cdot im\right)\right) \cdot \frac{1}{2} \]
        8. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \left(\cosh im - \left(2 \cdot im + 1\right)\right) \cdot \frac{1}{2} \]
          2. lower-fma.f6495.1

            \[\leadsto \left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5 \]
        9. Applied rewrites95.1%

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

      Alternative 4: 92.1% accurate, 1.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.1:\\ \;\;\;\;\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 2.1)
         (* (* (cos re) (fma -0.16666666666666666 (* im im) -1.0)) im)
         (* (* 0.5 (cos re)) (- 1.0 (exp im)))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 2.1) {
      		tmp = (cos(re) * fma(-0.16666666666666666, (im * im), -1.0)) * im;
      	} else {
      		tmp = (0.5 * cos(re)) * (1.0 - exp(im));
      	}
      	return tmp;
      }
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 2.1)
      		tmp = Float64(Float64(cos(re) * fma(-0.16666666666666666, Float64(im * im), -1.0)) * im);
      	else
      		tmp = Float64(Float64(0.5 * cos(re)) * Float64(1.0 - exp(im)));
      	end
      	return tmp
      end
      
      code[re_, im_] := If[LessEqual[im, 2.1], N[(N[(N[Cos[re], $MachinePrecision] * N[(-0.16666666666666666 * N[(im * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 2.1:\\
      \;\;\;\;\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(1 - e^{im}\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < 2.10000000000000009

        1. Initial program 37.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im \]
        4. Applied rewrites89.3%

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

        if 2.10000000000000009 < im

        1. Initial program 100.0%

          \[\left(0.5 \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 \left(\color{blue}{1} - e^{im}\right) \]
        3. Step-by-step derivation
          1. Applied rewrites99.8%

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\color{blue}{1} - e^{im}\right) \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 5: 91.9% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -100:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\left(-\cos re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\ \end{array} \end{array} \]
        (FPCore (re im)
         :precision binary64
         (let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
           (if (<= t_0 -100.0)
             (* (* -2.0 (sinh im)) 0.5)
             (if (<= t_0 0.0)
               (* (- (cos re)) im)
               (* (- (cosh im) (fma 2.0 im 1.0)) 0.5)))))
        double code(double re, double im) {
        	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
        	double tmp;
        	if (t_0 <= -100.0) {
        		tmp = (-2.0 * sinh(im)) * 0.5;
        	} else if (t_0 <= 0.0) {
        		tmp = -cos(re) * im;
        	} else {
        		tmp = (cosh(im) - fma(2.0, im, 1.0)) * 0.5;
        	}
        	return tmp;
        }
        
        function code(re, im)
        	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
        	tmp = 0.0
        	if (t_0 <= -100.0)
        		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
        	elseif (t_0 <= 0.0)
        		tmp = Float64(Float64(-cos(re)) * im);
        	else
        		tmp = Float64(Float64(cosh(im) - fma(2.0, im, 1.0)) * 0.5);
        	end
        	return tmp
        end
        
        code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[((-N[Cos[re], $MachinePrecision]) * im), $MachinePrecision], N[(N[(N[Cosh[im], $MachinePrecision] - N[(2.0 * im + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
        \mathbf{if}\;t\_0 \leq -100:\\
        \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
        
        \mathbf{elif}\;t\_0 \leq 0:\\
        \;\;\;\;\left(-\cos re\right) \cdot im\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\
        
        
        \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))) < -100

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
          3. Step-by-step derivation
            1. Applied rewrites74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \frac{1}{2} \]
              14. lift-sinh.f6474.3

                \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot 0.5 \]
            3. Applied rewrites74.3%

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

            if -100 < (*.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 6.8%

              \[\left(0.5 \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. mul-1-negN/A

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

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

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

                \[\leadsto \left(-1 \cdot \cos re\right) \cdot im \]
              5. lower-*.f64N/A

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

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

                \[\leadsto \left(-\cos re\right) \cdot im \]
              8. lift-cos.f6499.3

                \[\leadsto \left(-\cos re\right) \cdot im \]
            4. Applied rewrites99.3%

              \[\leadsto \color{blue}{\left(-\cos re\right) \cdot 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 97.7%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
              3. negate-sub2N/A

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

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

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

                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
              7. lower-sinh.f6473.2

                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
            4. Applied rewrites73.2%

              \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
            5. Step-by-step derivation
              1. lift-neg.f64N/A

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

                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
              3. lift-sinh.f64N/A

                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
              4. sinh-undef-revN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
              5. negate-sub2N/A

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
              6. negate-subN/A

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              7. sinh---cosh-revN/A

                \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              8. associate--r-N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              9. lift-cosh.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              10. lift-sinh.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              11. lift-neg.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              12. lift-exp.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              13. lift--.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              14. lift--.f6472.0

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
            6. Applied rewrites72.0%

              \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
            7. Taylor expanded in im around 0

              \[\leadsto \left(\cosh im - \left(1 + 2 \cdot im\right)\right) \cdot \frac{1}{2} \]
            8. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \left(\cosh im - \left(2 \cdot im + 1\right)\right) \cdot \frac{1}{2} \]
              2. lower-fma.f6495.1

                \[\leadsto \left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5 \]
            9. Applied rewrites95.1%

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

          Alternative 6: 70.9% accurate, 1.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\ \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (if (<= (* 0.5 (cos re)) -0.01)
             (* (- (cosh im) (fma 2.0 im 1.0)) 0.5)
             (* (* -2.0 (sinh im)) 0.5)))
          double code(double re, double im) {
          	double tmp;
          	if ((0.5 * cos(re)) <= -0.01) {
          		tmp = (cosh(im) - fma(2.0, im, 1.0)) * 0.5;
          	} else {
          		tmp = (-2.0 * sinh(im)) * 0.5;
          	}
          	return tmp;
          }
          
          function code(re, im)
          	tmp = 0.0
          	if (Float64(0.5 * cos(re)) <= -0.01)
          		tmp = Float64(Float64(cosh(im) - fma(2.0, im, 1.0)) * 0.5);
          	else
          		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
          	end
          	return tmp
          end
          
          code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[(N[Cosh[im], $MachinePrecision] - N[(2.0 * im + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\
          \;\;\;\;\left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0100000000000000002

            1. Initial program 54.0%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
              3. negate-sub2N/A

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

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

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

                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
              7. lower-sinh.f642.0

                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
            4. Applied rewrites2.0%

              \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
            5. Step-by-step derivation
              1. lift-neg.f64N/A

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

                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
              3. lift-sinh.f64N/A

                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
              4. sinh-undef-revN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
              5. negate-sub2N/A

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
              6. negate-subN/A

                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              7. sinh---cosh-revN/A

                \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              8. associate--r-N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              9. lift-cosh.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              10. lift-sinh.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
              11. lift-neg.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              12. lift-exp.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              13. lift--.f64N/A

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
              14. lift--.f642.7

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
            6. Applied rewrites2.7%

              \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
            7. Taylor expanded in im around 0

              \[\leadsto \left(\cosh im - \left(1 + 2 \cdot im\right)\right) \cdot \frac{1}{2} \]
            8. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \left(\cosh im - \left(2 \cdot im + 1\right)\right) \cdot \frac{1}{2} \]
              2. lower-fma.f6426.8

                \[\leadsto \left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5 \]
            9. Applied rewrites26.8%

              \[\leadsto \left(\cosh im - \mathsf{fma}\left(2, im, 1\right)\right) \cdot 0.5 \]

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

            1. Initial program 52.8%

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

              \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
            3. Step-by-step derivation
              1. Applied rewrites52.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \frac{1}{2} \]
                14. lift-sinh.f6485.5

                  \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot 0.5 \]
              3. Applied rewrites85.5%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
            4. Recombined 2 regimes into one program.
            5. Add Preprocessing

            Alternative 7: 70.9% accurate, 1.1× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\ \;\;\;\;\left(\cosh im - 1\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \end{array} \end{array} \]
            (FPCore (re im)
             :precision binary64
             (if (<= (* 0.5 (cos re)) -0.01)
               (* (- (cosh im) 1.0) 0.5)
               (* (* -2.0 (sinh im)) 0.5)))
            double code(double re, double im) {
            	double tmp;
            	if ((0.5 * cos(re)) <= -0.01) {
            		tmp = (cosh(im) - 1.0) * 0.5;
            	} else {
            		tmp = (-2.0 * sinh(im)) * 0.5;
            	}
            	return tmp;
            }
            
            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
                real(8) :: tmp
                if ((0.5d0 * cos(re)) <= (-0.01d0)) then
                    tmp = (cosh(im) - 1.0d0) * 0.5d0
                else
                    tmp = ((-2.0d0) * sinh(im)) * 0.5d0
                end if
                code = tmp
            end function
            
            public static double code(double re, double im) {
            	double tmp;
            	if ((0.5 * Math.cos(re)) <= -0.01) {
            		tmp = (Math.cosh(im) - 1.0) * 0.5;
            	} else {
            		tmp = (-2.0 * Math.sinh(im)) * 0.5;
            	}
            	return tmp;
            }
            
            def code(re, im):
            	tmp = 0
            	if (0.5 * math.cos(re)) <= -0.01:
            		tmp = (math.cosh(im) - 1.0) * 0.5
            	else:
            		tmp = (-2.0 * math.sinh(im)) * 0.5
            	return tmp
            
            function code(re, im)
            	tmp = 0.0
            	if (Float64(0.5 * cos(re)) <= -0.01)
            		tmp = Float64(Float64(cosh(im) - 1.0) * 0.5);
            	else
            		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
            	end
            	return tmp
            end
            
            function tmp_2 = code(re, im)
            	tmp = 0.0;
            	if ((0.5 * cos(re)) <= -0.01)
            		tmp = (cosh(im) - 1.0) * 0.5;
            	else
            		tmp = (-2.0 * sinh(im)) * 0.5;
            	end
            	tmp_2 = tmp;
            end
            
            code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[(N[Cosh[im], $MachinePrecision] - 1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\
            \;\;\;\;\left(\cosh im - 1\right) \cdot 0.5\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0100000000000000002

              1. Initial program 54.0%

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

                \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

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

                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                3. negate-sub2N/A

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                7. lower-sinh.f642.0

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
              4. Applied rewrites2.0%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
              5. Step-by-step derivation
                1. lift-neg.f64N/A

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

                  \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                3. lift-sinh.f64N/A

                  \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                4. sinh-undef-revN/A

                  \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
                5. negate-sub2N/A

                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
                6. negate-subN/A

                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                7. sinh---cosh-revN/A

                  \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                8. associate--r-N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                9. lift-cosh.f64N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                10. lift-sinh.f64N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                11. lift-neg.f64N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                12. lift-exp.f64N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                13. lift--.f64N/A

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                14. lift--.f642.7

                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
              6. Applied rewrites2.7%

                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
              7. Taylor expanded in im around 0

                \[\leadsto \left(\cosh im - 1\right) \cdot \frac{1}{2} \]
              8. Step-by-step derivation
                1. Applied rewrites26.9%

                  \[\leadsto \left(\cosh im - 1\right) \cdot 0.5 \]

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

                1. Initial program 52.8%

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

                  \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites52.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \frac{1}{2} \]
                    14. lift-sinh.f6485.5

                      \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot 0.5 \]
                  3. Applied rewrites85.5%

                    \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 8: 70.0% accurate, 0.4× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -100:\\ \;\;\;\;0.5 \cdot \left(1 - e^{im}\right)\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh im - 1\right) \cdot 0.5\\ \end{array} \end{array} \]
                (FPCore (re im)
                 :precision binary64
                 (let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
                   (if (<= t_0 -100.0)
                     (* 0.5 (- 1.0 (exp im)))
                     (if (<= t_0 0.0) (- im) (* (- (cosh im) 1.0) 0.5)))))
                double code(double re, double im) {
                	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
                	double tmp;
                	if (t_0 <= -100.0) {
                		tmp = 0.5 * (1.0 - exp(im));
                	} else if (t_0 <= 0.0) {
                		tmp = -im;
                	} else {
                		tmp = (cosh(im) - 1.0) * 0.5;
                	}
                	return tmp;
                }
                
                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
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
                    if (t_0 <= (-100.0d0)) then
                        tmp = 0.5d0 * (1.0d0 - exp(im))
                    else if (t_0 <= 0.0d0) then
                        tmp = -im
                    else
                        tmp = (cosh(im) - 1.0d0) * 0.5d0
                    end if
                    code = tmp
                end function
                
                public static double code(double re, double im) {
                	double t_0 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
                	double tmp;
                	if (t_0 <= -100.0) {
                		tmp = 0.5 * (1.0 - Math.exp(im));
                	} else if (t_0 <= 0.0) {
                		tmp = -im;
                	} else {
                		tmp = (Math.cosh(im) - 1.0) * 0.5;
                	}
                	return tmp;
                }
                
                def code(re, im):
                	t_0 = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
                	tmp = 0
                	if t_0 <= -100.0:
                		tmp = 0.5 * (1.0 - math.exp(im))
                	elif t_0 <= 0.0:
                		tmp = -im
                	else:
                		tmp = (math.cosh(im) - 1.0) * 0.5
                	return tmp
                
                function code(re, im)
                	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
                	tmp = 0.0
                	if (t_0 <= -100.0)
                		tmp = Float64(0.5 * Float64(1.0 - exp(im)));
                	elseif (t_0 <= 0.0)
                		tmp = Float64(-im);
                	else
                		tmp = Float64(Float64(cosh(im) - 1.0) * 0.5);
                	end
                	return tmp
                end
                
                function tmp_2 = code(re, im)
                	t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
                	tmp = 0.0;
                	if (t_0 <= -100.0)
                		tmp = 0.5 * (1.0 - exp(im));
                	elseif (t_0 <= 0.0)
                		tmp = -im;
                	else
                		tmp = (cosh(im) - 1.0) * 0.5;
                	end
                	tmp_2 = tmp;
                end
                
                code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(0.5 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], (-im), N[(N[(N[Cosh[im], $MachinePrecision] - 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
                \mathbf{if}\;t\_0 \leq -100:\\
                \;\;\;\;0.5 \cdot \left(1 - e^{im}\right)\\
                
                \mathbf{elif}\;t\_0 \leq 0:\\
                \;\;\;\;-im\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\cosh im - 1\right) \cdot 0.5\\
                
                
                \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))) < -100

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites74.3%

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

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

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

                      if -100 < (*.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 6.8%

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

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                      3. Step-by-step derivation
                        1. *-commutativeN/A

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

                          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                        3. negate-sub2N/A

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

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

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

                          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                        7. lower-sinh.f6455.6

                          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                      4. Applied rewrites55.6%

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

                        \[\leadsto -1 \cdot \color{blue}{im} \]
                      6. Step-by-step derivation
                        1. mul-1-negN/A

                          \[\leadsto \mathsf{neg}\left(im\right) \]
                        2. lower-neg.f6455.4

                          \[\leadsto -im \]
                      7. Applied rewrites55.4%

                        \[\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 97.7%

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

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                      3. Step-by-step derivation
                        1. *-commutativeN/A

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

                          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                        3. negate-sub2N/A

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

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

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

                          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                        7. lower-sinh.f6473.2

                          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                      4. Applied rewrites73.2%

                        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
                      5. Step-by-step derivation
                        1. lift-neg.f64N/A

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

                          \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                        3. lift-sinh.f64N/A

                          \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                        4. sinh-undef-revN/A

                          \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
                        5. negate-sub2N/A

                          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
                        6. negate-subN/A

                          \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                        7. sinh---cosh-revN/A

                          \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                        8. associate--r-N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                        9. lift-cosh.f64N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                        10. lift-sinh.f64N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                        11. lift-neg.f64N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                        12. lift-exp.f64N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                        13. lift--.f64N/A

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                        14. lift--.f6472.0

                          \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                      6. Applied rewrites72.0%

                        \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                      7. Taylor expanded in im around 0

                        \[\leadsto \left(\cosh im - 1\right) \cdot \frac{1}{2} \]
                      8. Step-by-step derivation
                        1. Applied rewrites93.9%

                          \[\leadsto \left(\cosh im - 1\right) \cdot 0.5 \]
                      9. Recombined 3 regimes into one program.
                      10. Add Preprocessing

                      Alternative 9: 58.1% accurate, 0.4× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -100:\\ \;\;\;\;0.5 \cdot \left(1 - e^{im}\right)\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5\\ \end{array} \end{array} \]
                      (FPCore (re im)
                       :precision binary64
                       (let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
                         (if (<= t_0 -100.0)
                           (* 0.5 (- 1.0 (exp im)))
                           (if (<= t_0 0.0) (- im) (* (- (fma (* im im) 0.5 1.0) 1.0) 0.5)))))
                      double code(double re, double im) {
                      	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
                      	double tmp;
                      	if (t_0 <= -100.0) {
                      		tmp = 0.5 * (1.0 - exp(im));
                      	} else if (t_0 <= 0.0) {
                      		tmp = -im;
                      	} else {
                      		tmp = (fma((im * im), 0.5, 1.0) - 1.0) * 0.5;
                      	}
                      	return tmp;
                      }
                      
                      function code(re, im)
                      	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
                      	tmp = 0.0
                      	if (t_0 <= -100.0)
                      		tmp = Float64(0.5 * Float64(1.0 - exp(im)));
                      	elseif (t_0 <= 0.0)
                      		tmp = Float64(-im);
                      	else
                      		tmp = Float64(Float64(fma(Float64(im * im), 0.5, 1.0) - 1.0) * 0.5);
                      	end
                      	return tmp
                      end
                      
                      code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(0.5 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], (-im), N[(N[(N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] - 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
                      \mathbf{if}\;t\_0 \leq -100:\\
                      \;\;\;\;0.5 \cdot \left(1 - e^{im}\right)\\
                      
                      \mathbf{elif}\;t\_0 \leq 0:\\
                      \;\;\;\;-im\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5\\
                      
                      
                      \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))) < -100

                        1. Initial program 100.0%

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

                          \[\leadsto \color{blue}{\frac{1}{2}} \cdot \left(e^{0 - im} - e^{im}\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites74.3%

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

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

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

                            if -100 < (*.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 6.8%

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

                              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                            3. Step-by-step derivation
                              1. *-commutativeN/A

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

                                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                              3. negate-sub2N/A

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

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

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

                                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                              7. lower-sinh.f6455.6

                                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                            4. Applied rewrites55.6%

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

                              \[\leadsto -1 \cdot \color{blue}{im} \]
                            6. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto \mathsf{neg}\left(im\right) \]
                              2. lower-neg.f6455.4

                                \[\leadsto -im \]
                            7. Applied rewrites55.4%

                              \[\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 97.7%

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

                              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                            3. Step-by-step derivation
                              1. *-commutativeN/A

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

                                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                              3. negate-sub2N/A

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

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

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

                                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                              7. lower-sinh.f6473.2

                                \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                            4. Applied rewrites73.2%

                              \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
                            5. Step-by-step derivation
                              1. lift-neg.f64N/A

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

                                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                              3. lift-sinh.f64N/A

                                \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                              4. sinh-undef-revN/A

                                \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
                              5. negate-sub2N/A

                                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
                              6. negate-subN/A

                                \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                              7. sinh---cosh-revN/A

                                \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                              8. associate--r-N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                              9. lift-cosh.f64N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                              10. lift-sinh.f64N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                              11. lift-neg.f64N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                              12. lift-exp.f64N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                              13. lift--.f64N/A

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                              14. lift--.f6472.0

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                            6. Applied rewrites72.0%

                              \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                            7. Taylor expanded in im around 0

                              \[\leadsto \left(\cosh im - 1\right) \cdot \frac{1}{2} \]
                            8. Step-by-step derivation
                              1. Applied rewrites93.9%

                                \[\leadsto \left(\cosh im - 1\right) \cdot 0.5 \]
                              2. Taylor expanded in im around 0

                                \[\leadsto \left(\left(1 + \frac{1}{2} \cdot {im}^{2}\right) - 1\right) \cdot \frac{1}{2} \]
                              3. Step-by-step derivation
                                1. +-commutativeN/A

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

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

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

                                  \[\leadsto \left(\mathsf{fma}\left(im \cdot im, \frac{1}{2}, 1\right) - 1\right) \cdot \frac{1}{2} \]
                                5. lift-*.f6447.4

                                  \[\leadsto \left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5 \]
                              4. Applied rewrites47.4%

                                \[\leadsto \left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5 \]
                            9. Recombined 3 regimes into one program.
                            10. Add Preprocessing

                            Alternative 10: 56.3% accurate, 1.2× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \cos re \leq 5.8 \cdot 10^{-254}:\\ \;\;\;\;\left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im\\ \end{array} \end{array} \]
                            (FPCore (re im)
                             :precision binary64
                             (if (<= (* 0.5 (cos re)) 5.8e-254)
                               (* (- (fma (* im im) 0.5 1.0) 1.0) 0.5)
                               (* (fma (* im im) -0.16666666666666666 -1.0) im)))
                            double code(double re, double im) {
                            	double tmp;
                            	if ((0.5 * cos(re)) <= 5.8e-254) {
                            		tmp = (fma((im * im), 0.5, 1.0) - 1.0) * 0.5;
                            	} else {
                            		tmp = fma((im * im), -0.16666666666666666, -1.0) * im;
                            	}
                            	return tmp;
                            }
                            
                            function code(re, im)
                            	tmp = 0.0
                            	if (Float64(0.5 * cos(re)) <= 5.8e-254)
                            		tmp = Float64(Float64(fma(Float64(im * im), 0.5, 1.0) - 1.0) * 0.5);
                            	else
                            		tmp = Float64(fma(Float64(im * im), -0.16666666666666666, -1.0) * im);
                            	end
                            	return tmp
                            end
                            
                            code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], 5.8e-254], N[(N[(N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] - 1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * im), $MachinePrecision]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;0.5 \cdot \cos re \leq 5.8 \cdot 10^{-254}:\\
                            \;\;\;\;\left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < 5.7999999999999999e-254

                              1. Initial program 54.1%

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

                                \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                              3. Step-by-step derivation
                                1. *-commutativeN/A

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

                                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                                3. negate-sub2N/A

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

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

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

                                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                                7. lower-sinh.f642.0

                                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                              4. Applied rewrites2.0%

                                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot 0.5} \]
                              5. Step-by-step derivation
                                1. lift-neg.f64N/A

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

                                  \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                                3. lift-sinh.f64N/A

                                  \[\leadsto \left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right) \cdot \frac{1}{2} \]
                                4. sinh-undef-revN/A

                                  \[\leadsto \left(\mathsf{neg}\left(\left(e^{im} - e^{\mathsf{neg}\left(im\right)}\right)\right)\right) \cdot \frac{1}{2} \]
                                5. negate-sub2N/A

                                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \frac{1}{2} \]
                                6. negate-subN/A

                                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                                7. sinh---cosh-revN/A

                                  \[\leadsto \left(\left(\cosh im - \sinh im\right) + \left(\mathsf{neg}\left(e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                                8. associate--r-N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                                9. lift-cosh.f64N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                                10. lift-sinh.f64N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(\mathsf{neg}\left(e^{im}\right)\right)\right)\right) \cdot \frac{1}{2} \]
                                11. lift-neg.f64N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                                12. lift-exp.f64N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                                13. lift--.f64N/A

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot \frac{1}{2} \]
                                14. lift--.f642.7

                                  \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                              6. Applied rewrites2.7%

                                \[\leadsto \left(\cosh im - \left(\sinh im - \left(-e^{im}\right)\right)\right) \cdot 0.5 \]
                              7. Taylor expanded in im around 0

                                \[\leadsto \left(\cosh im - 1\right) \cdot \frac{1}{2} \]
                              8. Step-by-step derivation
                                1. Applied rewrites26.9%

                                  \[\leadsto \left(\cosh im - 1\right) \cdot 0.5 \]
                                2. Taylor expanded in im around 0

                                  \[\leadsto \left(\left(1 + \frac{1}{2} \cdot {im}^{2}\right) - 1\right) \cdot \frac{1}{2} \]
                                3. Step-by-step derivation
                                  1. +-commutativeN/A

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

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

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

                                    \[\leadsto \left(\mathsf{fma}\left(im \cdot im, \frac{1}{2}, 1\right) - 1\right) \cdot \frac{1}{2} \]
                                  5. lift-*.f6415.1

                                    \[\leadsto \left(\mathsf{fma}\left(im \cdot im, 0.5, 1\right) - 1\right) \cdot 0.5 \]
                                4. Applied rewrites15.1%

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

                                if 5.7999999999999999e-254 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re))

                                1. Initial program 52.8%

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im \]
                                4. Applied rewrites84.0%

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

                                  \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2} - 1\right) \cdot im \]
                                6. Step-by-step derivation
                                  1. negate-subN/A

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

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

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

                                    \[\leadsto \mathsf{fma}\left({im}^{2}, \frac{-1}{6}, -1\right) \cdot im \]
                                  5. pow2N/A

                                    \[\leadsto \mathsf{fma}\left(im \cdot im, \frac{-1}{6}, -1\right) \cdot im \]
                                  6. lift-*.f6470.1

                                    \[\leadsto \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im \]
                                7. Applied rewrites70.1%

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

                              Alternative 11: 53.0% accurate, 5.4× speedup?

                              \[\begin{array}{l} \\ \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im \end{array} \]
                              (FPCore (re im)
                               :precision binary64
                               (* (fma (* im im) -0.16666666666666666 -1.0) im))
                              double code(double re, double im) {
                              	return fma((im * im), -0.16666666666666666, -1.0) * im;
                              }
                              
                              function code(re, im)
                              	return Float64(fma(Float64(im * im), -0.16666666666666666, -1.0) * im)
                              end
                              
                              code[re_, im_] := N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * im), $MachinePrecision]
                              
                              \begin{array}{l}
                              
                              \\
                              \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im
                              \end{array}
                              
                              Derivation
                              1. Initial program 53.1%

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666, im \cdot im, -1\right)\right) \cdot im \]
                              4. Applied rewrites84.2%

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

                                \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2} - 1\right) \cdot im \]
                              6. Step-by-step derivation
                                1. negate-subN/A

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

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

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

                                  \[\leadsto \mathsf{fma}\left({im}^{2}, \frac{-1}{6}, -1\right) \cdot im \]
                                5. pow2N/A

                                  \[\leadsto \mathsf{fma}\left(im \cdot im, \frac{-1}{6}, -1\right) \cdot im \]
                                6. lift-*.f6453.0

                                  \[\leadsto \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im \]
                              7. Applied rewrites53.0%

                                \[\leadsto \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im \]
                              8. Add Preprocessing

                              Alternative 12: 30.2% accurate, 32.7× speedup?

                              \[\begin{array}{l} \\ -im \end{array} \]
                              (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)
                              
                              \begin{array}{l}
                              
                              \\
                              -im
                              \end{array}
                              
                              Derivation
                              1. Initial program 53.1%

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

                                \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
                              3. Step-by-step derivation
                                1. *-commutativeN/A

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

                                  \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\frac{1}{2}} \]
                                3. negate-sub2N/A

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

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

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

                                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                                7. lower-sinh.f6464.7

                                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot 0.5 \]
                              4. Applied rewrites64.7%

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

                                \[\leadsto -1 \cdot \color{blue}{im} \]
                              6. Step-by-step derivation
                                1. mul-1-negN/A

                                  \[\leadsto \mathsf{neg}\left(im\right) \]
                                2. lower-neg.f6430.2

                                  \[\leadsto -im \]
                              7. Applied rewrites30.2%

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

                              Reproduce

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