math.sin on complex, imaginary part

Percentage Accurate: 54.7% → 99.9%
Time: 5.6s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 54.7% 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 54.7%

    \[\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-*.f64N/A

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - im} - \color{blue}{e^{im}}\right) \]
    8. 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) \]
    9. mul-1-negN/A

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

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

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

      \[\leadsto \color{blue}{\left(\cos re \cdot \left(e^{-1 \cdot im} - e^{im}\right)\right) \cdot \frac{1}{2}} \]
  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: 76.7% 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 -2 \cdot 10^{+30}:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 0.5:\\ \;\;\;\;\left(\cos re \cdot im\right) \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right)\\ \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 -2e+30)
     (* (* -2.0 (sinh im)) 0.5)
     (if (<= t_0 0.5)
       (* (* (cos re) im) (fma (* im im) -0.16666666666666666 -1.0))
       (* (* 0.25 (* re re)) (* (sinh im) 2.0))))))
double code(double re, double im) {
	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	double tmp;
	if (t_0 <= -2e+30) {
		tmp = (-2.0 * sinh(im)) * 0.5;
	} else if (t_0 <= 0.5) {
		tmp = (cos(re) * im) * fma((im * im), -0.16666666666666666, -1.0);
	} else {
		tmp = (0.25 * (re * re)) * (sinh(im) * 2.0);
	}
	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 <= -2e+30)
		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
	elseif (t_0 <= 0.5)
		tmp = Float64(Float64(cos(re) * im) * fma(Float64(im * im), -0.16666666666666666, -1.0));
	else
		tmp = Float64(Float64(0.25 * Float64(re * re)) * Float64(sinh(im) * 2.0));
	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, -2e+30], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.5], N[(N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(N[Sinh[im], $MachinePrecision] * 2.0), $MachinePrecision]), $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 -2 \cdot 10^{+30}:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\

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

\mathbf{else}:\\
\;\;\;\;\left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right)\\


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

    1. Initial program 54.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^{0 - im} - e^{im}\right) \]
    3. Step-by-step derivation
      1. Applied rewrites41.5%

        \[\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-exp.f64N/A

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{\color{blue}{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. sub-negate-revN/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.f6465.4

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

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

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

      1. Initial program 54.7%

        \[\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-*.f64N/A

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

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

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

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

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

          \[\leadsto \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{0 - im} - \color{blue}{e^{im}}\right) \]
        8. 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) \]
        9. mul-1-negN/A

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

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

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

          \[\leadsto \color{blue}{\left(\cos re \cdot \left(e^{-1 \cdot im} - e^{im}\right)\right) \cdot \frac{1}{2}} \]
      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. 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)} \]
      7. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

          \[\leadsto im \cdot \left(\cos re \cdot \left(\frac{-1}{6} \cdot \left(im \cdot im\right) - \left(\mathsf{neg}\left(\color{blue}{-1}\right)\right)\right)\right) \]
        8. pow2N/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. metadata-evalN/A

          \[\leadsto im \cdot \left(\cos re \cdot \left(\frac{-1}{6} \cdot {im}^{2} - 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. sub-flipN/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) \]
      8. Applied rewrites84.1%

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

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

      1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
      4. Applied rewrites62.7%

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
      5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
        12. lift-sinh.f6414.3

          \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
      7. Applied rewrites14.3%

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

    Alternative 3: 74.8% 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 -2 \cdot 10^{+30}:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 0.5:\\ \;\;\;\;\left(-im\right) \cdot \cos re\\ \mathbf{else}:\\ \;\;\;\;\left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right)\\ \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 -2e+30)
         (* (* -2.0 (sinh im)) 0.5)
         (if (<= t_0 0.5)
           (* (- im) (cos re))
           (* (* 0.25 (* re re)) (* (sinh im) 2.0))))))
    double code(double re, double im) {
    	double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
    	double tmp;
    	if (t_0 <= -2e+30) {
    		tmp = (-2.0 * sinh(im)) * 0.5;
    	} else if (t_0 <= 0.5) {
    		tmp = -im * cos(re);
    	} else {
    		tmp = (0.25 * (re * re)) * (sinh(im) * 2.0);
    	}
    	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 <= (-2d+30)) then
            tmp = ((-2.0d0) * sinh(im)) * 0.5d0
        else if (t_0 <= 0.5d0) then
            tmp = -im * cos(re)
        else
            tmp = (0.25d0 * (re * re)) * (sinh(im) * 2.0d0)
        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 <= -2e+30) {
    		tmp = (-2.0 * Math.sinh(im)) * 0.5;
    	} else if (t_0 <= 0.5) {
    		tmp = -im * Math.cos(re);
    	} else {
    		tmp = (0.25 * (re * re)) * (Math.sinh(im) * 2.0);
    	}
    	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 <= -2e+30:
    		tmp = (-2.0 * math.sinh(im)) * 0.5
    	elif t_0 <= 0.5:
    		tmp = -im * math.cos(re)
    	else:
    		tmp = (0.25 * (re * re)) * (math.sinh(im) * 2.0)
    	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 <= -2e+30)
    		tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5);
    	elseif (t_0 <= 0.5)
    		tmp = Float64(Float64(-im) * cos(re));
    	else
    		tmp = Float64(Float64(0.25 * Float64(re * re)) * Float64(sinh(im) * 2.0));
    	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 <= -2e+30)
    		tmp = (-2.0 * sinh(im)) * 0.5;
    	elseif (t_0 <= 0.5)
    		tmp = -im * cos(re);
    	else
    		tmp = (0.25 * (re * re)) * (sinh(im) * 2.0);
    	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, -2e+30], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.5], N[((-im) * N[Cos[re], $MachinePrecision]), $MachinePrecision], N[(N[(0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(N[Sinh[im], $MachinePrecision] * 2.0), $MachinePrecision]), $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 -2 \cdot 10^{+30}:\\
    \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
    
    \mathbf{elif}\;t\_0 \leq 0.5:\\
    \;\;\;\;\left(-im\right) \cdot \cos re\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -2e30

      1. Initial program 54.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^{0 - im} - e^{im}\right) \]
      3. Step-by-step derivation
        1. Applied rewrites41.5%

          \[\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-exp.f64N/A

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

            \[\leadsto \frac{1}{2} \cdot \left(e^{\color{blue}{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. sub-negate-revN/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.f6465.4

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

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

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

        1. Initial program 54.7%

          \[\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. associate-*r*N/A

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

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

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

            \[\leadsto \left(-im\right) \cdot \cos \color{blue}{re} \]
          5. lift-cos.f6451.6

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

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

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

        1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
        3. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
        4. Applied rewrites62.7%

          \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
        5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
          12. lift-sinh.f6414.3

            \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
        7. Applied rewrites14.3%

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

      Alternative 4: 74.6% accurate, 0.7× speedup?

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

        1. Initial program 54.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^{0 - im} - e^{im}\right) \]
        3. Step-by-step derivation
          1. Applied rewrites41.5%

            \[\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-exp.f64N/A

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

              \[\leadsto \frac{1}{2} \cdot \left(e^{\color{blue}{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. sub-negate-revN/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.f6465.4

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

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

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

          1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
          3. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
          4. Applied rewrites62.7%

            \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
          5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
            12. lift-sinh.f6414.3

              \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
          7. Applied rewrites14.3%

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

        Alternative 5: 52.4% accurate, 1.1× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \cos re \leq -0.005:\\ \;\;\;\;\left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)\\ \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.005)
           (* (* (* (* im im) im) -0.3333333333333333) (fma (* re re) -0.25 0.5))
           (* (* -2.0 (sinh im)) 0.5)))
        double code(double re, double im) {
        	double tmp;
        	if ((0.5 * cos(re)) <= -0.005) {
        		tmp = (((im * im) * im) * -0.3333333333333333) * fma((re * re), -0.25, 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.005)
        		tmp = Float64(Float64(Float64(Float64(im * im) * im) * -0.3333333333333333) * fma(Float64(re * re), -0.25, 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.005], N[(N[(N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision]), $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.005:\\
        \;\;\;\;\left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)\\
        
        \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.0050000000000000001

          1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
          3. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
          4. Applied rewrites62.7%

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

            \[\leadsto \left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right) \cdot \mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{4}, \frac{1}{2}\right) \]
          6. Step-by-step derivation
            1. sinh-undef-revN/A

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

              \[\leadsto \left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right) \cdot \mathsf{fma}\left(\color{blue}{re} \cdot re, \frac{-1}{4}, \frac{1}{2}\right) \]
            3. sub0-negN/A

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

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

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

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

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

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

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

              \[\leadsto \left(\mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right) \cdot im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \]
          7. Applied rewrites54.2%

            \[\leadsto \left(\mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right) \cdot im\right) \cdot \mathsf{fma}\left(\color{blue}{re \cdot re}, -0.25, 0.5\right) \]
          8. Taylor expanded in im around inf

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

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

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

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

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

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

              \[\leadsto \left(\left(\left(im \cdot im\right) \cdot im\right) \cdot \frac{-1}{3}\right) \cdot \mathsf{fma}\left(re \cdot re, \frac{-1}{4}, \frac{1}{2}\right) \]
            7. lift-*.f6431.6

              \[\leadsto \left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \]
          10. Applied rewrites31.6%

            \[\leadsto \left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \mathsf{fma}\left(re \cdot \color{blue}{re}, -0.25, 0.5\right) \]

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

          1. Initial program 54.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^{0 - im} - e^{im}\right) \]
          3. Step-by-step derivation
            1. Applied rewrites41.5%

              \[\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-exp.f64N/A

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

                \[\leadsto \frac{1}{2} \cdot \left(e^{\color{blue}{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. sub-negate-revN/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.f6465.4

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

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

          Alternative 6: 51.0% accurate, 0.7× speedup?

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

            1. Initial program 54.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^{0 - im} - e^{im}\right) \]
            3. Step-by-step derivation
              1. Applied rewrites41.5%

                \[\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-exp.f64N/A

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

                  \[\leadsto \frac{1}{2} \cdot \left(e^{\color{blue}{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. sub-negate-revN/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.f6465.4

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

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

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

              1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
              4. Applied rewrites62.7%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
              5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
                12. lift-sinh.f6414.3

                  \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
              7. Applied rewrites14.3%

                \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(\sinh im \cdot 2\right)} \]
              8. Taylor expanded in im around 0

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

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

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

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

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

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

                  \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
              10. Applied rewrites11.6%

                \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
            4. Recombined 2 regimes into one program.
            5. Add Preprocessing

            Alternative 7: 45.2% accurate, 0.8× speedup?

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

              1. Initial program 54.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. sub0-negN/A

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

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

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \frac{1}{2} \]
                9. lower-sinh.f6465.4

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

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

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

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

                  \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2} - 1\right) \cdot im \]
                3. sub-flipN/A

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

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

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

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

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

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

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

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

              1. Initial program 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
              4. Applied rewrites62.7%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
              5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
                12. lift-sinh.f6414.3

                  \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
              7. Applied rewrites14.3%

                \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(\sinh im \cdot 2\right)} \]
              8. Taylor expanded in im around 0

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

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

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

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

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

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

                  \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
              10. Applied rewrites11.6%

                \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 8: 45.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 -2 \cdot 10^{+30}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(\left(re \cdot re\right) \cdot im\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 -2e+30)
                 (* (* (* im im) -0.16666666666666666) im)
                 (if (<= t_0 0.0) (- im) (* (* (* re re) im) 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 <= -2e+30) {
            		tmp = ((im * im) * -0.16666666666666666) * im;
            	} else if (t_0 <= 0.0) {
            		tmp = -im;
            	} else {
            		tmp = ((re * re) * 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) :: t_0
                real(8) :: tmp
                t_0 = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
                if (t_0 <= (-2d+30)) then
                    tmp = ((im * im) * (-0.16666666666666666d0)) * im
                else if (t_0 <= 0.0d0) then
                    tmp = -im
                else
                    tmp = ((re * re) * im) * 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 <= -2e+30) {
            		tmp = ((im * im) * -0.16666666666666666) * im;
            	} else if (t_0 <= 0.0) {
            		tmp = -im;
            	} else {
            		tmp = ((re * re) * im) * 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 <= -2e+30:
            		tmp = ((im * im) * -0.16666666666666666) * im
            	elif t_0 <= 0.0:
            		tmp = -im
            	else:
            		tmp = ((re * re) * im) * 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 <= -2e+30)
            		tmp = Float64(Float64(Float64(im * im) * -0.16666666666666666) * im);
            	elseif (t_0 <= 0.0)
            		tmp = Float64(-im);
            	else
            		tmp = Float64(Float64(Float64(re * re) * im) * 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 <= -2e+30)
            		tmp = ((im * im) * -0.16666666666666666) * im;
            	elseif (t_0 <= 0.0)
            		tmp = -im;
            	else
            		tmp = ((re * re) * im) * 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, -2e+30], N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] * im), $MachinePrecision], If[LessEqual[t$95$0, 0.0], (-im), N[(N[(N[(re * re), $MachinePrecision] * im), $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 -2 \cdot 10^{+30}:\\
            \;\;\;\;\left(\left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\\
            
            \mathbf{elif}\;t\_0 \leq 0:\\
            \;\;\;\;-im\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(\left(re \cdot re\right) \cdot im\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))) < -2e30

              1. Initial program 54.7%

                \[\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. unpow2N/A

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(\cos re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, 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. sub-flipN/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.8

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

                \[\leadsto \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im \]
              8. Taylor expanded in im around inf

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

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

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

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

                  \[\leadsto \left(\left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im \]
              10. Applied rewrites29.4%

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

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

              1. Initial program 54.7%

                \[\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. associate-*r*N/A

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

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

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

                  \[\leadsto \left(-im\right) \cdot \cos \color{blue}{re} \]
                5. lift-cos.f6451.6

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

                \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
              5. Taylor expanded in re 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. lift-neg.f6429.4

                  \[\leadsto -im \]
              7. Applied rewrites29.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 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
              4. Applied rewrites62.7%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
              5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
                12. lift-sinh.f6414.3

                  \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
              7. Applied rewrites14.3%

                \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(\sinh im \cdot 2\right)} \]
              8. Taylor expanded in im around 0

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

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

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

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

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

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

                  \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
              10. Applied rewrites11.6%

                \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
            3. Recombined 3 regimes into one program.
            4. Add Preprocessing

            Alternative 9: 32.6% accurate, 0.8× speedup?

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

              1. Initial program 54.7%

                \[\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. associate-*r*N/A

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

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

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

                  \[\leadsto \left(-im\right) \cdot \cos \color{blue}{re} \]
                5. lift-cos.f6451.6

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

                \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
              5. Taylor expanded in re 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. lift-neg.f6429.4

                  \[\leadsto -im \]
              7. Applied rewrites29.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 54.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}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left({re}^{2}, \color{blue}{\frac{-1}{4}}, \frac{1}{2}\right) \]
              4. Applied rewrites62.7%

                \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)} \]
              5. Taylor expanded in re around inf

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\frac{1}{4} \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
                12. lift-sinh.f6414.3

                  \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(\sinh im \cdot 2\right) \]
              7. Applied rewrites14.3%

                \[\leadsto \left(0.25 \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(\sinh im \cdot 2\right)} \]
              8. Taylor expanded in im around 0

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

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

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

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

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

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

                  \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
              10. Applied rewrites11.6%

                \[\leadsto \left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 10: 29.4% 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 54.7%

              \[\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. associate-*r*N/A

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

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

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

                \[\leadsto \left(-im\right) \cdot \cos \color{blue}{re} \]
              5. lift-cos.f6451.6

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

              \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
            5. Taylor expanded in re 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. lift-neg.f6429.4

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

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

            Reproduce

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