math.cos on complex, imaginary part

Percentage Accurate: 65.7% → 99.9%
Time: 11.3s
Alternatives: 19
Speedup: 1.4×

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}

Sampling outcomes in binary64 precision:

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 19 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.7% 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.0× speedup?

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

\\
\left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \cosh im\right) \cdot \tanh \left(-im\right)\right)
\end{array}
Derivation
  1. Initial program 67.7%

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

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{e^{-im} \cdot e^{-im} - e^{im} \cdot e^{im}}{e^{-im} + e^{im}}} \]
    3. difference-of-squaresN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \frac{e^{-im} - e^{im}}{e^{-im} + e^{im}}\right) \]
  4. Applied rewrites99.9%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(2 \cdot \cosh im\right) \cdot \tanh \left(-im\right)\right)} \]
  5. Add Preprocessing

Alternative 2: 81.3% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := t\_0 \cdot \left(e^{-im} - e^{im}\right)\\
t_2 := \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+197}:\\
\;\;\;\;\left(\sinh \left(-im\right) \cdot 2\right) \cdot \left(re \cdot 0.5\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot t\_2, re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, t\_2, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\


\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))) < -9.9999999999999995e196

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6474.0

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    5. Applied rewrites74.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Applied rewrites74.0%

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

    if -9.9999999999999995e196 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-7

    1. Initial program 33.4%

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    5. Applied rewrites99.2%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]

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

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
    5. Applied rewrites78.7%

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

      \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
    7. Step-by-step derivation
      1. Applied rewrites57.6%

        \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
      2. Taylor expanded in re around 0

        \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
      3. Step-by-step derivation
        1. Applied rewrites8.3%

          \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
        2. Taylor expanded in im around 0

          \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
        3. Step-by-step derivation
          1. Applied rewrites49.7%

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

        Alternative 3: 81.3% accurate, 0.4× speedup?

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

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
          4. Step-by-step derivation
            1. lower-*.f6474.0

              \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
          5. Applied rewrites74.0%

            \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
          6. Applied rewrites74.0%

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

          if -9.9999999999999995e196 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-7

          1. Initial program 33.4%

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

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

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

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

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

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

          1. Initial program 100.0%

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

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

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

              \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
          5. Applied rewrites78.7%

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

            \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
          7. Step-by-step derivation
            1. Applied rewrites57.6%

              \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
            2. Taylor expanded in re around 0

              \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
            3. Step-by-step derivation
              1. Applied rewrites8.3%

                \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
              2. Taylor expanded in im around 0

                \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
              3. Step-by-step derivation
                1. Applied rewrites49.7%

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

              Alternative 4: 81.2% accurate, 0.4× speedup?

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

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                4. Step-by-step derivation
                  1. lower-*.f6474.0

                    \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                5. Applied rewrites74.0%

                  \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                6. Applied rewrites74.0%

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

                if -9.9999999999999995e196 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-7

                1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 100.0%

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

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

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

                    \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                5. Applied rewrites78.7%

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

                  \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                7. Step-by-step derivation
                  1. Applied rewrites57.6%

                    \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                  2. Taylor expanded in re around 0

                    \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
                  3. Step-by-step derivation
                    1. Applied rewrites8.3%

                      \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                    2. Taylor expanded in im around 0

                      \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
                    3. Step-by-step derivation
                      1. Applied rewrites49.7%

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

                    Alternative 5: 80.5% accurate, 0.4× speedup?

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

                      1. Initial program 99.6%

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

                        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                      4. Step-by-step derivation
                        1. lower-*.f6473.4

                          \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                      5. Applied rewrites73.4%

                        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                      6. Applied rewrites73.4%

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

                      if -1.00000000000000006e-32 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-7

                      1. Initial program 32.6%

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 100.0%

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

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

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

                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                      5. Applied rewrites78.7%

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

                        \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                      7. Step-by-step derivation
                        1. Applied rewrites57.6%

                          \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                        2. Taylor expanded in re around 0

                          \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
                        3. Step-by-step derivation
                          1. Applied rewrites8.3%

                            \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                          2. Taylor expanded in im around 0

                            \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
                          3. Step-by-step derivation
                            1. Applied rewrites49.7%

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

                          Alternative 6: 79.1% accurate, 0.4× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+197}:\\ \;\;\;\;\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-7}:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot t\_1, re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, t\_1, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\ \end{array} \end{array} \]
                          (FPCore (re im)
                           :precision binary64
                           (let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
                                  (t_1 (fma -0.0001984126984126984 (* re re) 0.008333333333333333)))
                             (if (<= t_0 -1e+197)
                               (*
                                (*
                                 (-
                                  (*
                                   (*
                                    (-
                                     (*
                                      (*
                                       (- (* (* im im) -0.0003968253968253968) 0.016666666666666666)
                                       im)
                                      im)
                                     0.3333333333333333)
                                    im)
                                   im)
                                  2.0)
                                 im)
                                (* re 0.5))
                               (if (<= t_0 2e-7)
                                 (* (- (sin re)) im)
                                 (*
                                  (*
                                   (fma
                                    (-
                                     (*
                                      (fma (* -0.16666666666666666 t_1) (* re re) 0.027777777777777776)
                                      (* re re))
                                     0.16666666666666666)
                                    (* im im)
                                    (- (* (fma (* (- re) re) t_1 0.16666666666666666) (* re re)) 1.0))
                                   re)
                                  im)))))
                          double code(double re, double im) {
                          	double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
                          	double t_1 = fma(-0.0001984126984126984, (re * re), 0.008333333333333333);
                          	double tmp;
                          	if (t_0 <= -1e+197) {
                          		tmp = ((((((((((im * im) * -0.0003968253968253968) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * im) * im) - 2.0) * im) * (re * 0.5);
                          	} else if (t_0 <= 2e-7) {
                          		tmp = -sin(re) * im;
                          	} else {
                          		tmp = (fma(((fma((-0.16666666666666666 * t_1), (re * re), 0.027777777777777776) * (re * re)) - 0.16666666666666666), (im * im), ((fma((-re * re), t_1, 0.16666666666666666) * (re * re)) - 1.0)) * re) * im;
                          	}
                          	return tmp;
                          }
                          
                          function code(re, im)
                          	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
                          	t_1 = fma(-0.0001984126984126984, Float64(re * re), 0.008333333333333333)
                          	tmp = 0.0
                          	if (t_0 <= -1e+197)
                          		tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(im * im) * -0.0003968253968253968) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * im) * im) - 2.0) * im) * Float64(re * 0.5));
                          	elseif (t_0 <= 2e-7)
                          		tmp = Float64(Float64(-sin(re)) * im);
                          	else
                          		tmp = Float64(Float64(fma(Float64(Float64(fma(Float64(-0.16666666666666666 * t_1), Float64(re * re), 0.027777777777777776) * Float64(re * re)) - 0.16666666666666666), Float64(im * im), Float64(Float64(fma(Float64(Float64(-re) * re), t_1, 0.16666666666666666) * Float64(re * re)) - 1.0)) * re) * im);
                          	end
                          	return tmp
                          end
                          
                          code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(re * re), $MachinePrecision] + 0.008333333333333333), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+197], N[(N[(N[(N[(N[(N[(N[(N[(N[(N[(N[(im * im), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-7], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(-0.16666666666666666 * t$95$1), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.027777777777777776), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision] + N[(N[(N[(N[((-re) * re), $MachinePrecision] * t$95$1 + 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
                          t_1 := \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right)\\
                          \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+197}:\\
                          \;\;\;\;\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)\\
                          
                          \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-7}:\\
                          \;\;\;\;\left(-\sin re\right) \cdot im\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot t\_1, re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, t\_1, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\
                          
                          
                          \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))) < -9.9999999999999995e196

                            1. Initial program 100.0%

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

                              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                            4. Step-by-step derivation
                              1. lower-*.f6474.0

                                \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                            5. Applied rewrites74.0%

                              \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                            6. Applied rewrites74.0%

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

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

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

                                \[\leadsto \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot \frac{1}{2}\right) \]
                            9. Applied rewrites67.0%

                              \[\leadsto \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot 0.5\right) \]
                            10. Step-by-step derivation
                              1. Applied rewrites67.0%

                                \[\leadsto \color{blue}{\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)} \]

                              if -9.9999999999999995e196 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1.9999999999999999e-7

                              1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

                              1. Initial program 100.0%

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

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

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

                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                              5. Applied rewrites78.7%

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

                                \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                              7. Step-by-step derivation
                                1. Applied rewrites57.6%

                                  \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                2. Taylor expanded in re around 0

                                  \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
                                3. Step-by-step derivation
                                  1. Applied rewrites8.3%

                                    \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                  2. Taylor expanded in im around 0

                                    \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites49.7%

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

                                  Alternative 7: 55.3% accurate, 0.8× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right)\\ \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq 0:\\ \;\;\;\;\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot t\_0, re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, t\_0, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\ \end{array} \end{array} \]
                                  (FPCore (re im)
                                   :precision binary64
                                   (let* ((t_0 (fma -0.0001984126984126984 (* re re) 0.008333333333333333)))
                                     (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) 0.0)
                                       (*
                                        (*
                                         (-
                                          (*
                                           (*
                                            (-
                                             (*
                                              (*
                                               (- (* (* im im) -0.0003968253968253968) 0.016666666666666666)
                                               im)
                                              im)
                                             0.3333333333333333)
                                            im)
                                           im)
                                          2.0)
                                         im)
                                        (* re 0.5))
                                       (*
                                        (*
                                         (fma
                                          (-
                                           (*
                                            (fma (* -0.16666666666666666 t_0) (* re re) 0.027777777777777776)
                                            (* re re))
                                           0.16666666666666666)
                                          (* im im)
                                          (- (* (fma (* (- re) re) t_0 0.16666666666666666) (* re re)) 1.0))
                                         re)
                                        im))))
                                  double code(double re, double im) {
                                  	double t_0 = fma(-0.0001984126984126984, (re * re), 0.008333333333333333);
                                  	double tmp;
                                  	if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= 0.0) {
                                  		tmp = ((((((((((im * im) * -0.0003968253968253968) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * im) * im) - 2.0) * im) * (re * 0.5);
                                  	} else {
                                  		tmp = (fma(((fma((-0.16666666666666666 * t_0), (re * re), 0.027777777777777776) * (re * re)) - 0.16666666666666666), (im * im), ((fma((-re * re), t_0, 0.16666666666666666) * (re * re)) - 1.0)) * re) * im;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  function code(re, im)
                                  	t_0 = fma(-0.0001984126984126984, Float64(re * re), 0.008333333333333333)
                                  	tmp = 0.0
                                  	if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= 0.0)
                                  		tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(im * im) * -0.0003968253968253968) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * im) * im) - 2.0) * im) * Float64(re * 0.5));
                                  	else
                                  		tmp = Float64(Float64(fma(Float64(Float64(fma(Float64(-0.16666666666666666 * t_0), Float64(re * re), 0.027777777777777776) * Float64(re * re)) - 0.16666666666666666), Float64(im * im), Float64(Float64(fma(Float64(Float64(-re) * re), t_0, 0.16666666666666666) * Float64(re * re)) - 1.0)) * re) * im);
                                  	end
                                  	return tmp
                                  end
                                  
                                  code[re_, im_] := Block[{t$95$0 = N[(-0.0001984126984126984 * N[(re * re), $MachinePrecision] + 0.008333333333333333), $MachinePrecision]}, If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(N[(N[(N[(N[(N[(N[(N[(N[(im * im), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(-0.16666666666666666 * t$95$0), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.027777777777777776), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision] + N[(N[(N[(N[((-re) * re), $MachinePrecision] * t$95$0 + 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  t_0 := \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right)\\
                                  \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq 0:\\
                                  \;\;\;\;\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot t\_0, re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, t\_0, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\
                                  
                                  
                                  \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))) < -0.0

                                    1. Initial program 57.4%

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

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

                                        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                    5. Applied rewrites47.6%

                                      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                    6. Applied rewrites59.3%

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

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

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

                                        \[\leadsto \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot \frac{1}{2}\right) \]
                                    9. Applied rewrites56.3%

                                      \[\leadsto \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot 0.5\right) \]
                                    10. Step-by-step derivation
                                      1. Applied rewrites56.3%

                                        \[\leadsto \color{blue}{\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)} \]

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

                                      1. Initial program 96.8%

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

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

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

                                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                                      5. Applied rewrites80.0%

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

                                        \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites58.6%

                                          \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                        2. Taylor expanded in re around 0

                                          \[\leadsto \left(re \cdot \left(\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right) + {re}^{2} \cdot \left(\frac{-1}{5040} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + \frac{1}{120} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)\right)\right) - 1\right)\right) \cdot im \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites12.3%

                                            \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot -0.16666666666666666\right), re \cdot re, \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                          2. Taylor expanded in im around 0

                                            \[\leadsto \left(\left(\left({im}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{36} + \frac{-1}{6} \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right) - \frac{1}{6}\right) + {re}^{2} \cdot \left(\frac{1}{6} + -1 \cdot \left({re}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {re}^{2}\right)\right)\right)\right) - 1\right) \cdot re\right) \cdot im \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites51.3%

                                              \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), re \cdot re, 0.027777777777777776\right) \cdot \left(re \cdot re\right) - 0.16666666666666666, im \cdot im, \mathsf{fma}\left(\left(-re\right) \cdot re, \mathsf{fma}\left(-0.0001984126984126984, re \cdot re, 0.008333333333333333\right), 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im \]
                                          4. Recombined 2 regimes into one program.
                                          5. Add Preprocessing

                                          Alternative 8: 74.3% accurate, 1.0× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 0.0006:\\ \;\;\;\;t\_0 \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \left(im \cdot im\right) - 1\right) \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
                                          (FPCore (re im)
                                           :precision binary64
                                           (let* ((t_0 (* 0.5 (sin re))))
                                             (if (<= im 0.0006)
                                               (*
                                                t_0
                                                (*
                                                 (* 2.0 (fma (* im im) 0.5 1.0))
                                                 (* (- (* 0.3333333333333333 (* im im)) 1.0) im)))
                                               (* t_0 (- (exp (- im)) (exp im))))))
                                          double code(double re, double im) {
                                          	double t_0 = 0.5 * sin(re);
                                          	double tmp;
                                          	if (im <= 0.0006) {
                                          		tmp = t_0 * ((2.0 * fma((im * im), 0.5, 1.0)) * (((0.3333333333333333 * (im * im)) - 1.0) * im));
                                          	} else {
                                          		tmp = t_0 * (exp(-im) - exp(im));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(re, im)
                                          	t_0 = Float64(0.5 * sin(re))
                                          	tmp = 0.0
                                          	if (im <= 0.0006)
                                          		tmp = Float64(t_0 * Float64(Float64(2.0 * fma(Float64(im * im), 0.5, 1.0)) * Float64(Float64(Float64(0.3333333333333333 * Float64(im * im)) - 1.0) * im)));
                                          	else
                                          		tmp = Float64(t_0 * Float64(exp(Float64(-im)) - exp(im)));
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0006], N[(t$95$0 * N[(N[(2.0 * N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          t_0 := 0.5 \cdot \sin re\\
                                          \mathbf{if}\;im \leq 0.0006:\\
                                          \;\;\;\;t\_0 \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \left(im \cdot im\right) - 1\right) \cdot im\right)\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;t\_0 \cdot \left(e^{-im} - e^{im}\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if im < 5.99999999999999947e-4

                                            1. Initial program 55.6%

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{e^{-im} \cdot e^{-im} - e^{im} \cdot e^{im}}{e^{-im} + e^{im}}} \]
                                              3. difference-of-squaresN/A

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \frac{e^{-im} - e^{im}}{e^{-im} + e^{im}}\right) \]
                                            4. Applied rewrites99.9%

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{2}, 1\right)\right) \cdot \tanh \left(-im\right)\right) \]
                                              5. lower-*.f6483.1

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, 0.5, 1\right)\right) \cdot \tanh \left(-im\right)\right) \]
                                            7. Applied rewrites83.1%

                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \color{blue}{\mathsf{fma}\left(im \cdot im, 0.5, 1\right)}\right) \cdot \tanh \left(-im\right)\right) \]
                                            8. Taylor expanded in im around 0

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, \frac{1}{2}, 1\right)\right) \cdot \left(\left(\frac{1}{3} \cdot \color{blue}{\left(im \cdot im\right)} - 1\right) \cdot im\right)\right) \]
                                              6. lower-*.f6466.1

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \color{blue}{\left(im \cdot im\right)} - 1\right) \cdot im\right)\right) \]
                                            10. Applied rewrites66.1%

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

                                            if 5.99999999999999947e-4 < im

                                            1. Initial program 100.0%

                                              \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                            2. Add Preprocessing
                                          3. Recombined 2 regimes into one program.
                                          4. Add Preprocessing

                                          Alternative 9: 74.2% accurate, 1.4× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 0.94:\\ \;\;\;\;t\_0 \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \left(im \cdot im\right) - 1\right) \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(\left(1 - im\right) - e^{im}\right)\\ \end{array} \end{array} \]
                                          (FPCore (re im)
                                           :precision binary64
                                           (let* ((t_0 (* 0.5 (sin re))))
                                             (if (<= im 0.94)
                                               (*
                                                t_0
                                                (*
                                                 (* 2.0 (fma (* im im) 0.5 1.0))
                                                 (* (- (* 0.3333333333333333 (* im im)) 1.0) im)))
                                               (* t_0 (- (- 1.0 im) (exp im))))))
                                          double code(double re, double im) {
                                          	double t_0 = 0.5 * sin(re);
                                          	double tmp;
                                          	if (im <= 0.94) {
                                          		tmp = t_0 * ((2.0 * fma((im * im), 0.5, 1.0)) * (((0.3333333333333333 * (im * im)) - 1.0) * im));
                                          	} else {
                                          		tmp = t_0 * ((1.0 - im) - exp(im));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(re, im)
                                          	t_0 = Float64(0.5 * sin(re))
                                          	tmp = 0.0
                                          	if (im <= 0.94)
                                          		tmp = Float64(t_0 * Float64(Float64(2.0 * fma(Float64(im * im), 0.5, 1.0)) * Float64(Float64(Float64(0.3333333333333333 * Float64(im * im)) - 1.0) * im)));
                                          	else
                                          		tmp = Float64(t_0 * Float64(Float64(1.0 - im) - exp(im)));
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.94], N[(t$95$0 * N[(N[(2.0 * N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          t_0 := 0.5 \cdot \sin re\\
                                          \mathbf{if}\;im \leq 0.94:\\
                                          \;\;\;\;t\_0 \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \left(im \cdot im\right) - 1\right) \cdot im\right)\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;t\_0 \cdot \left(\left(1 - im\right) - e^{im}\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if im < 0.93999999999999995

                                            1. Initial program 55.6%

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\frac{e^{-im} \cdot e^{-im} - e^{im} \cdot e^{im}}{e^{-im} + e^{im}}} \]
                                              3. difference-of-squaresN/A

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \frac{e^{-im} - e^{im}}{e^{-im} + e^{im}}\right) \]
                                            4. Applied rewrites99.9%

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{2}, 1\right)\right) \cdot \tanh \left(-im\right)\right) \]
                                              5. lower-*.f6483.1

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, 0.5, 1\right)\right) \cdot \tanh \left(-im\right)\right) \]
                                            7. Applied rewrites83.1%

                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \color{blue}{\mathsf{fma}\left(im \cdot im, 0.5, 1\right)}\right) \cdot \tanh \left(-im\right)\right) \]
                                            8. Taylor expanded in im around 0

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

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

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, \frac{1}{2}, 1\right)\right) \cdot \left(\left(\frac{1}{3} \cdot \color{blue}{\left(im \cdot im\right)} - 1\right) \cdot im\right)\right) \]
                                              6. lower-*.f6466.1

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(2 \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\right) \cdot \left(\left(0.3333333333333333 \cdot \color{blue}{\left(im \cdot im\right)} - 1\right) \cdot im\right)\right) \]
                                            10. Applied rewrites66.1%

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

                                            if 0.93999999999999995 < im

                                            1. Initial program 100.0%

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

                                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(1 + -1 \cdot im\right)} - e^{im}\right) \]
                                            4. Step-by-step derivation
                                              1. fp-cancel-sign-sub-invN/A

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(1 - \color{blue}{im}\right) - e^{im}\right) \]
                                              4. lower--.f6499.0

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(1 - im\right)} - e^{im}\right) \]
                                            5. Applied rewrites99.0%

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

                                          Alternative 10: 58.6% accurate, 1.9× speedup?

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

                                            1. Initial program 55.0%

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

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

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

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

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

                                              \[\leadsto \left(re \cdot \left(\left(\frac{-1}{6} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + {im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right)\right) - 1\right)\right) \cdot im \]
                                            7. Step-by-step derivation
                                              1. Applied rewrites26.9%

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

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

                                              1. Initial program 72.9%

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

                                                \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                              4. Step-by-step derivation
                                                1. lower-*.f6463.2

                                                  \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                              5. Applied rewrites63.2%

                                                \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                              6. Applied rewrites76.7%

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

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

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

                                                  \[\leadsto \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot \frac{1}{2}\right) \]
                                              9. Applied rewrites70.9%

                                                \[\leadsto \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \cdot \left(re \cdot 0.5\right) \]
                                              10. Step-by-step derivation
                                                1. Applied rewrites70.9%

                                                  \[\leadsto \color{blue}{\left(\left(\left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.0003968253968253968 - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right)} \]
                                              11. Recombined 2 regimes into one program.
                                              12. Add Preprocessing

                                              Alternative 11: 56.6% accurate, 1.9× speedup?

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

                                                1. Initial program 68.1%

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

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

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

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

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

                                                  \[\leadsto \left(re \cdot \left(\left(\frac{-1}{6} \cdot \left({re}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) + {im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right)\right) - 1\right)\right) \cdot im \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites54.9%

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

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

                                                  1. Initial program 67.3%

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

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

                                                      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                                  5. Applied rewrites52.4%

                                                    \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                                  6. Applied rewrites65.1%

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \left(\left(\left(\left(\frac{-1}{60} \cdot \color{blue}{\left(im \cdot im\right)} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot \frac{1}{2}\right) \]
                                                    12. lower-*.f6458.8

                                                      \[\leadsto \left(\left(\left(\left(-0.016666666666666666 \cdot \color{blue}{\left(im \cdot im\right)} - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right) \]
                                                  9. Applied rewrites58.8%

                                                    \[\leadsto \color{blue}{\left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)} \cdot \left(re \cdot 0.5\right) \]
                                                8. Recombined 2 regimes into one program.
                                                9. Add Preprocessing

                                                Alternative 12: 57.1% accurate, 2.1× speedup?

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

                                                  1. Initial program 55.0%

                                                    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                  2. Add Preprocessing
                                                  3. Applied rewrites48.4%

                                                    \[\leadsto \color{blue}{\frac{\left(\left(2 \cdot \sinh \left(-3 \cdot im\right)\right) \cdot \sin re\right) \cdot 0.5}{\mathsf{fma}\left(2, \cosh \left(-2 \cdot im\right), 1\right)}} \]
                                                  4. Taylor expanded in im around 0

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

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

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

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

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

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

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

                                                    1. Initial program 72.9%

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

                                                      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                                    4. Step-by-step derivation
                                                      1. lower-*.f6463.2

                                                        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                                    5. Applied rewrites63.2%

                                                      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
                                                    6. Applied rewrites76.7%

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

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

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

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \left(\left(\left(\left(\frac{-1}{60} \cdot \color{blue}{\left(im \cdot im\right)} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot \frac{1}{2}\right) \]
                                                      12. lower-*.f6469.9

                                                        \[\leadsto \left(\left(\left(\left(-0.016666666666666666 \cdot \color{blue}{\left(im \cdot im\right)} - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \cdot \left(re \cdot 0.5\right) \]
                                                    9. Applied rewrites69.9%

                                                      \[\leadsto \color{blue}{\left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)} \cdot \left(re \cdot 0.5\right) \]
                                                  9. Recombined 2 regimes into one program.
                                                  10. Add Preprocessing

                                                  Alternative 13: 56.1% accurate, 2.1× speedup?

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

                                                    1. Initial program 55.0%

                                                      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                    2. Add Preprocessing
                                                    3. Applied rewrites48.4%

                                                      \[\leadsto \color{blue}{\frac{\left(\left(2 \cdot \sinh \left(-3 \cdot im\right)\right) \cdot \sin re\right) \cdot 0.5}{\mathsf{fma}\left(2, \cosh \left(-2 \cdot im\right), 1\right)}} \]
                                                    4. Taylor expanded in im around 0

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

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

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

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

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

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

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

                                                      1. Initial program 72.9%

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

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

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

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

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

                                                        \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                      7. Step-by-step derivation
                                                        1. Applied rewrites68.8%

                                                          \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                        2. Taylor expanded in re around 0

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

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

                                                        Alternative 14: 55.2% accurate, 2.1× speedup?

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

                                                          1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                          7. Step-by-step derivation
                                                            1. Applied rewrites20.1%

                                                              \[\leadsto \left(-re\right) \cdot im \]
                                                            2. 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)} \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites24.4%

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

                                                                \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites24.4%

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

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

                                                                1. Initial program 72.9%

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

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

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

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

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

                                                                  \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                                7. Step-by-step derivation
                                                                  1. Applied rewrites68.8%

                                                                    \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                                  2. Taylor expanded in re around 0

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

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

                                                                  Alternative 15: 53.8% accurate, 2.2× speedup?

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

                                                                    1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                    7. Step-by-step derivation
                                                                      1. Applied rewrites20.1%

                                                                        \[\leadsto \left(-re\right) \cdot im \]
                                                                      2. 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)} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites24.4%

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

                                                                          \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites24.4%

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

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

                                                                          1. Initial program 72.9%

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

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

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

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

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

                                                                            \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                                          7. Step-by-step derivation
                                                                            1. Applied rewrites68.8%

                                                                              \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                                            2. Taylor expanded in re around 0

                                                                              \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites68.8%

                                                                                \[\leadsto \left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                                              2. Taylor expanded in im around 0

                                                                                \[\leadsto \left(-1 \cdot re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot re + \frac{-1}{120} \cdot \left({im}^{2} \cdot re\right)\right)\right) \cdot im \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites67.4%

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

                                                                              Alternative 16: 52.4% accurate, 2.3× speedup?

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

                                                                                1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

                                                                                  \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                                7. Step-by-step derivation
                                                                                  1. Applied rewrites20.1%

                                                                                    \[\leadsto \left(-re\right) \cdot im \]
                                                                                  2. 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)} \]
                                                                                  3. Step-by-step derivation
                                                                                    1. Applied rewrites24.4%

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

                                                                                      \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                                                    3. Step-by-step derivation
                                                                                      1. Applied rewrites24.4%

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

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

                                                                                      1. Initial program 72.9%

                                                                                        \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                                      2. Add Preprocessing
                                                                                      3. Applied rewrites48.2%

                                                                                        \[\leadsto \color{blue}{\frac{\left(\left(2 \cdot \sinh \left(-3 \cdot im\right)\right) \cdot \sin re\right) \cdot 0.5}{\mathsf{fma}\left(2, \cosh \left(-2 \cdot im\right), 1\right)}} \]
                                                                                      4. Taylor expanded in im around 0

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

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

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

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

                                                                                        \[\leadsto im \cdot \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {im}^{2} - 1\right)\right)} \]
                                                                                      8. Step-by-step derivation
                                                                                        1. Applied rewrites66.2%

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

                                                                                      Alternative 17: 49.7% accurate, 2.4× speedup?

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

                                                                                        1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

                                                                                          \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                                        7. Step-by-step derivation
                                                                                          1. Applied rewrites20.1%

                                                                                            \[\leadsto \left(-re\right) \cdot im \]
                                                                                          2. 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)} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites24.4%

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

                                                                                              \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                                                            3. Step-by-step derivation
                                                                                              1. Applied rewrites24.4%

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

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

                                                                                              1. Initial program 72.9%

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

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

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

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

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

                                                                                                \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                                                              7. Step-by-step derivation
                                                                                                1. Applied rewrites68.8%

                                                                                                  \[\leadsto \left(\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                                                                2. Taylor expanded in re around 0

                                                                                                  \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
                                                                                                3. Step-by-step derivation
                                                                                                  1. Applied rewrites68.8%

                                                                                                    \[\leadsto \left(\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right) \cdot re\right) \cdot im \]
                                                                                                  2. Taylor expanded in im around 0

                                                                                                    \[\leadsto \left(-1 \cdot re + \frac{-1}{6} \cdot \left({im}^{2} \cdot re\right)\right) \cdot im \]
                                                                                                  3. Step-by-step derivation
                                                                                                    1. Applied rewrites63.0%

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

                                                                                                  Alternative 18: 34.6% accurate, 2.4× speedup?

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

                                                                                                    1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

                                                                                                      \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                                                    7. Step-by-step derivation
                                                                                                      1. Applied rewrites20.1%

                                                                                                        \[\leadsto \left(-re\right) \cdot im \]
                                                                                                      2. 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)} \]
                                                                                                      3. Step-by-step derivation
                                                                                                        1. Applied rewrites24.4%

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

                                                                                                          \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                                                                        3. Step-by-step derivation
                                                                                                          1. Applied rewrites24.4%

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

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

                                                                                                          1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

                                                                                                            \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                                                          7. Step-by-step derivation
                                                                                                            1. Applied rewrites39.9%

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

                                                                                                          Alternative 19: 32.5% accurate, 39.5× speedup?

                                                                                                          \[\begin{array}{l} \\ \left(-re\right) \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}
                                                                                                          
                                                                                                          \\
                                                                                                          \left(-re\right) \cdot im
                                                                                                          \end{array}
                                                                                                          
                                                                                                          Derivation
                                                                                                          1. Initial program 67.7%

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

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

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

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

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

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

                                                                                                              \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
                                                                                                            6. lower-sin.f6450.4

                                                                                                              \[\leadsto \left(-\color{blue}{\sin re}\right) \cdot im \]
                                                                                                          5. Applied rewrites50.4%

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

                                                                                                            \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                                                                                          7. Step-by-step derivation
                                                                                                            1. Applied rewrites34.2%

                                                                                                              \[\leadsto \left(-re\right) \cdot im \]
                                                                                                            2. Add Preprocessing

                                                                                                            Developer Target 1: 99.8% accurate, 1.0× speedup?

                                                                                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
                                                                                                            (FPCore (re im)
                                                                                                             :precision binary64
                                                                                                             (if (< (fabs im) 1.0)
                                                                                                               (-
                                                                                                                (*
                                                                                                                 (sin re)
                                                                                                                 (+
                                                                                                                  (+ im (* (* (* 0.16666666666666666 im) im) im))
                                                                                                                  (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
                                                                                                               (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
                                                                                                            double code(double re, double im) {
                                                                                                            	double tmp;
                                                                                                            	if (fabs(im) < 1.0) {
                                                                                                            		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                                            	} else {
                                                                                                            		tmp = (0.5 * sin(re)) * (exp(-im) - exp(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 (abs(im) < 1.0d0) then
                                                                                                                    tmp = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
                                                                                                                else
                                                                                                                    tmp = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
                                                                                                                end if
                                                                                                                code = tmp
                                                                                                            end function
                                                                                                            
                                                                                                            public static double code(double re, double im) {
                                                                                                            	double tmp;
                                                                                                            	if (Math.abs(im) < 1.0) {
                                                                                                            		tmp = -(Math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                                            	} else {
                                                                                                            		tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
                                                                                                            	}
                                                                                                            	return tmp;
                                                                                                            }
                                                                                                            
                                                                                                            def code(re, im):
                                                                                                            	tmp = 0
                                                                                                            	if math.fabs(im) < 1.0:
                                                                                                            		tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
                                                                                                            	else:
                                                                                                            		tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
                                                                                                            	return tmp
                                                                                                            
                                                                                                            function code(re, im)
                                                                                                            	tmp = 0.0
                                                                                                            	if (abs(im) < 1.0)
                                                                                                            		tmp = Float64(-Float64(sin(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
                                                                                                            	else
                                                                                                            		tmp = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)));
                                                                                                            	end
                                                                                                            	return tmp
                                                                                                            end
                                                                                                            
                                                                                                            function tmp_2 = code(re, im)
                                                                                                            	tmp = 0.0;
                                                                                                            	if (abs(im) < 1.0)
                                                                                                            		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                                            	else
                                                                                                            		tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
                                                                                                            	end
                                                                                                            	tmp_2 = tmp;
                                                                                                            end
                                                                                                            
                                                                                                            code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                                                            
                                                                                                            \begin{array}{l}
                                                                                                            
                                                                                                            \\
                                                                                                            \begin{array}{l}
                                                                                                            \mathbf{if}\;\left|im\right| < 1:\\
                                                                                                            \;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
                                                                                                            
                                                                                                            \mathbf{else}:\\
                                                                                                            \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
                                                                                                            
                                                                                                            
                                                                                                            \end{array}
                                                                                                            \end{array}
                                                                                                            

                                                                                                            Reproduce

                                                                                                            ?
                                                                                                            herbie shell --seed 2024346 
                                                                                                            (FPCore (re im)
                                                                                                              :name "math.cos on complex, imaginary part"
                                                                                                              :precision binary64
                                                                                                            
                                                                                                              :alt
                                                                                                              (! :herbie-platform default (if (< (fabs im) 1) (- (* (sin re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (sin re)) (- (exp (- im)) (exp im)))))
                                                                                                            
                                                                                                              (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))