math.cos on complex, imaginary part

Percentage Accurate: 65.2% → 99.9%
Time: 6.5s
Alternatives: 8
Speedup: 1.3×

Specification

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

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

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-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 8 alternatives:

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

Initial Program: 65.2% accurate, 1.0× speedup?

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

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

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.9% accurate, 1.3× speedup?

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

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

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sinh(-im) * sin(re)
end function
public static double code(double re, double im) {
	return Math.sinh(-im) * Math.sin(re);
}
def code(re, im):
	return math.sinh(-im) * math.sin(re)
function code(re, im)
	return Float64(sinh(Float64(-im)) * sin(re))
end
function tmp = code(re, im)
	tmp = sinh(-im) * sin(re);
end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sinh \left(-im\right) \cdot \sin re
\end{array}
Derivation
  1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \sinh \left(-im\right)\\
t_1 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-216}:\\
\;\;\;\;t\_0 \cdot re\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right) \cdot re} \]
      3. Applied rewrites63.8%

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

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sin re \cdot \left(-im\right) \]
        7. lower-*.f6452.3

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

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

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sinh \left(-im\right) \cdot \mathsf{fma}\left({re}^{2} \cdot re, \color{blue}{\frac{-1}{6}}, re\right) \]
        10. lower-*.f6463.2

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

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

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

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

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

    Alternative 3: 63.2% accurate, 0.9× speedup?

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sinh \left(-im\right) \cdot \mathsf{fma}\left({re}^{2} \cdot re, \color{blue}{\frac{-1}{6}}, re\right) \]
        10. lower-*.f6463.2

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

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

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

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

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

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\left(1 - \color{blue}{\cosh im}\right) - \sinh im\right) \]
            8. lower-sinh.f6434.5

              \[\leadsto \left(0.5 \cdot re\right) \cdot \left(\left(1 - \cosh im\right) - \color{blue}{\sinh im}\right) \]
          3. Applied rewrites34.5%

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

        Alternative 4: 60.4% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sinh \left(-im\right)\\ \mathbf{if}\;0.5 \cdot \sin re \leq 0.002:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(re \cdot re\right) \cdot re, -0.16666666666666666, re\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot re\\ \end{array} \end{array} \]
        (FPCore (re im)
         :precision binary64
         (let* ((t_0 (sinh (- im))))
           (if (<= (* 0.5 (sin re)) 0.002)
             (* t_0 (fma (* (* re re) re) -0.16666666666666666 re))
             (* t_0 re))))
        double code(double re, double im) {
        	double t_0 = sinh(-im);
        	double tmp;
        	if ((0.5 * sin(re)) <= 0.002) {
        		tmp = t_0 * fma(((re * re) * re), -0.16666666666666666, re);
        	} else {
        		tmp = t_0 * re;
        	}
        	return tmp;
        }
        
        function code(re, im)
        	t_0 = sinh(Float64(-im))
        	tmp = 0.0
        	if (Float64(0.5 * sin(re)) <= 0.002)
        		tmp = Float64(t_0 * fma(Float64(Float64(re * re) * re), -0.16666666666666666, re));
        	else
        		tmp = Float64(t_0 * re);
        	end
        	return tmp
        end
        
        code[re_, im_] := Block[{t$95$0 = N[Sinh[(-im)], $MachinePrecision]}, If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.002], N[(t$95$0 * N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * -0.16666666666666666 + re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * re), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \sinh \left(-im\right)\\
        \mathbf{if}\;0.5 \cdot \sin re \leq 0.002:\\
        \;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(re \cdot re\right) \cdot re, -0.16666666666666666, re\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0 \cdot re\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 2e-3

          1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sinh \left(-im\right) \cdot \mathsf{fma}\left({re}^{2} \cdot re, \color{blue}{\frac{-1}{6}}, re\right) \]
            10. lower-*.f6463.2

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

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

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

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

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

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

          1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right) \cdot re} \]
            3. Applied rewrites63.8%

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

          Alternative 5: 49.9% accurate, 0.8× speedup?

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

            1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right) \cdot re} \]
              3. Applied rewrites63.8%

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

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

              1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 6: 35.2% accurate, 1.2× speedup?

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

              1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 65.2%

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

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

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

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

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

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

                \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
              6. Step-by-step derivation
                1. lower-*.f6433.9

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

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

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

                  \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
                3. lower-neg.f6433.9

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

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

                  \[\leadsto -re \cdot im \]
                6. lower-*.f6433.9

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

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

            Alternative 7: 35.2% accurate, 1.2× speedup?

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

              1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 65.2%

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

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

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

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

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

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

                \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
              6. Step-by-step derivation
                1. lower-*.f6433.9

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

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

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

                  \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
                3. lower-neg.f6433.9

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

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

                  \[\leadsto -re \cdot im \]
                6. lower-*.f6433.9

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

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

            Alternative 8: 33.9% accurate, 12.7× speedup?

            \[\begin{array}{l} \\ -re \cdot im \end{array} \]
            (FPCore (re im) :precision binary64 (- (* re im)))
            double code(double re, double im) {
            	return -(re * im);
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(re, im)
            use fmin_fmax_functions
                real(8), intent (in) :: re
                real(8), intent (in) :: im
                code = -(re * im)
            end function
            
            public static double code(double re, double im) {
            	return -(re * im);
            }
            
            def code(re, im):
            	return -(re * im)
            
            function code(re, im)
            	return Float64(-Float64(re * im))
            end
            
            function tmp = code(re, im)
            	tmp = -(re * im);
            end
            
            code[re_, im_] := (-N[(re * im), $MachinePrecision])
            
            \begin{array}{l}
            
            \\
            -re \cdot im
            \end{array}
            
            Derivation
            1. Initial program 65.2%

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

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

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

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

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

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

              \[\leadsto -1 \cdot \left(im \cdot \color{blue}{re}\right) \]
            6. Step-by-step derivation
              1. lower-*.f6433.9

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

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

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

                \[\leadsto \mathsf{neg}\left(im \cdot re\right) \]
              3. lower-neg.f6433.9

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

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

                \[\leadsto -re \cdot im \]
              6. lower-*.f6433.9

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

              \[\leadsto \color{blue}{-re \cdot im} \]
            10. Add Preprocessing

            Reproduce

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