math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.0s
Alternatives: 20
Speedup: 1.5×

Specification

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

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

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

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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 20 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: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

\\
\begin{array}{l}
t_0 := e^{-im}\\
\left(0.5 \cdot \sin re\right) \cdot \left(t\_0 + \frac{1}{t\_0}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
    15. lower-sinh.f6455.8

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
    16. lift--.f64N/A

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
    18. lower-neg.f6455.8

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
  4. Applied rewrites55.8%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
  5. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{-im}}\right) \]
    8. sinh-cosh100.0

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\color{blue}{1}}{e^{-im}}\right) \]
  7. Final simplification100.0%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \frac{1}{e^{-im}}\right) \]
  8. Add Preprocessing

Alternative 2: 83.5% 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)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im)))))
   (if (<= t_0 (- INFINITY))
     (*
      (* (* 2.0 (cosh im)) (* (fma -0.16666666666666666 (* re re) 1.0) re))
      0.5)
     (if (<= t_0 1.0)
       (* (fma (* 0.5 im) im 1.0) (sin re))
       (*
        (* 0.5 re)
        (fma
         (fma
          (fma 0.002777777777777778 (* im im) 0.08333333333333333)
          (* im im)
          1.0)
         (* im im)
         2.0))))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = ((2.0 * cosh(im)) * (fma(-0.16666666666666666, (re * re), 1.0) * re)) * 0.5;
	} else if (t_0 <= 1.0) {
		tmp = fma((0.5 * im), im, 1.0) * sin(re);
	} else {
		tmp = (0.5 * re) * fma(fma(fma(0.002777777777777778, (im * im), 0.08333333333333333), (im * im), 1.0), (im * im), 2.0);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(Float64(2.0 * cosh(im)) * Float64(fma(-0.16666666666666666, Float64(re * re), 1.0) * re)) * 0.5);
	elseif (t_0 <= 1.0)
		tmp = Float64(fma(Float64(0.5 * im), im, 1.0) * sin(re));
	else
		tmp = Float64(Float64(0.5 * re) * fma(fma(fma(0.002777777777777778, Float64(im * im), 0.08333333333333333), Float64(im * im), 1.0), Float64(im * im), 2.0));
	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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(N[(-0.16666666666666666 * N[(re * re), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(0.002777777777777778 * N[(im * im), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\

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

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(2 \cdot \cosh im\right)} \cdot \sin re\right) \cdot \frac{1}{2} \]
      16. lower-cosh.f64100.0

        \[\leadsto \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \sin re\right) \cdot 0.5 \]
    4. Applied rewrites100.0%

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
      10. lower-sin.f6498.8

        \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
    5. Applied rewrites98.8%

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
      15. lower-sinh.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
      16. lift--.f64N/A

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
      18. lower-neg.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
    4. Applied rewrites0.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
    5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
      14. lower-*.f6477.4

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
    7. Applied rewrites77.4%

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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    9. Step-by-step derivation
      1. lower-*.f6467.9

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    10. Applied rewrites67.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.4% 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(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot t\_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
        (t_1
         (fma
          (fma
           (fma 0.002777777777777778 (* im im) 0.08333333333333333)
           (* im im)
           1.0)
          (* im im)
          2.0)))
   (if (<= t_0 (- INFINITY))
     (* (* (fma (* re re) -0.08333333333333333 0.5) re) t_1)
     (if (<= t_0 1.0)
       (* (fma (* 0.5 im) im 1.0) (sin re))
       (* (* 0.5 re) t_1)))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
	double t_1 = fma(fma(fma(0.002777777777777778, (im * im), 0.08333333333333333), (im * im), 1.0), (im * im), 2.0);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * t_1;
	} else if (t_0 <= 1.0) {
		tmp = fma((0.5 * im), im, 1.0) * sin(re);
	} else {
		tmp = (0.5 * re) * t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im)))
	t_1 = fma(fma(fma(0.002777777777777778, Float64(im * im), 0.08333333333333333), Float64(im * im), 1.0), Float64(im * im), 2.0)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * t_1);
	elseif (t_0 <= 1.0)
		tmp = Float64(fma(Float64(0.5 * im), im, 1.0) * sin(re));
	else
		tmp = Float64(Float64(0.5 * re) * t_1);
	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[(N[(N[(0.002777777777777778 * N[(im * im), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * t$95$1), $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(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot t\_1\\


\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
      15. lower-sinh.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
      16. lift--.f64N/A

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
      18. lower-neg.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
    4. Applied rewrites0.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
    5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
    7. Applied rewrites85.3%

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
      7. lower-*.f6462.3

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    10. Applied rewrites62.3%

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

    if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
      10. lower-sin.f6498.8

        \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
    5. Applied rewrites98.8%

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
      15. lower-sinh.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
      16. lift--.f64N/A

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
      18. lower-neg.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
    4. Applied rewrites0.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
    5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
      14. lower-*.f6477.4

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
    7. Applied rewrites77.4%

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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    9. Step-by-step derivation
      1. lower-*.f6467.9

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    10. Applied rewrites67.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.0% 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(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;1 \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot t\_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
        (t_1
         (fma
          (fma
           (fma 0.002777777777777778 (* im im) 0.08333333333333333)
           (* im im)
           1.0)
          (* im im)
          2.0)))
   (if (<= t_0 (- INFINITY))
     (* (* (fma (* re re) -0.08333333333333333 0.5) re) t_1)
     (if (<= t_0 1.0) (* 1.0 (sin re)) (* (* 0.5 re) t_1)))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
	double t_1 = fma(fma(fma(0.002777777777777778, (im * im), 0.08333333333333333), (im * im), 1.0), (im * im), 2.0);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * t_1;
	} else if (t_0 <= 1.0) {
		tmp = 1.0 * sin(re);
	} else {
		tmp = (0.5 * re) * t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im)))
	t_1 = fma(fma(fma(0.002777777777777778, Float64(im * im), 0.08333333333333333), Float64(im * im), 1.0), Float64(im * im), 2.0)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * t_1);
	elseif (t_0 <= 1.0)
		tmp = Float64(1.0 * sin(re));
	else
		tmp = Float64(Float64(0.5 * re) * t_1);
	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[(N[(N[(0.002777777777777778 * N[(im * im), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(1.0 * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * t$95$1), $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(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;1 \cdot \sin re\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot t\_1\\


\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
      15. lower-sinh.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
      16. lift--.f64N/A

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
      18. lower-neg.f640.0

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
    4. Applied rewrites0.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
    5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
    7. Applied rewrites85.3%

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
      7. lower-*.f6462.3

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    10. Applied rewrites62.3%

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

    if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
      10. lower-sin.f6498.8

        \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
    5. Applied rewrites98.8%

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

      \[\leadsto 1 \cdot \sin \color{blue}{re} \]
    7. Step-by-step derivation
      1. Applied rewrites98.1%

        \[\leadsto 1 \cdot \sin \color{blue}{re} \]

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
        15. lower-sinh.f640.0

          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
        16. lift--.f64N/A

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

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
        18. lower-neg.f640.0

          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
      4. Applied rewrites0.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
      5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
        14. lower-*.f6477.4

          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
      7. Applied rewrites77.4%

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

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
      9. Step-by-step derivation
        1. lower-*.f6467.9

          \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
      10. Applied rewrites67.9%

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
    8. Recombined 3 regimes into one program.
    9. Final simplification83.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;1 \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \]
    10. Add Preprocessing

    Alternative 5: 44.4% accurate, 0.9× speedup?

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
            2. Step-by-step derivation
              1. Applied rewrites64.4%

                \[\leadsto \mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, 1 \cdot re\right) \]
            3. Recombined 2 regimes into one program.
            4. Final simplification49.1%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(re \cdot im\right) \cdot re, -0.08333333333333333, 0.5 \cdot im\right) \cdot re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, re\right)\\ \end{array} \]
            5. Add Preprocessing

            Alternative 6: 47.1% accurate, 0.9× speedup?

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

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                    2. Step-by-step derivation
                      1. Applied rewrites64.4%

                        \[\leadsto \mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, 1 \cdot re\right) \]
                    3. Recombined 2 regimes into one program.
                    4. Final simplification52.4%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot im\right) \cdot im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, re\right)\\ \end{array} \]
                    5. Add Preprocessing

                    Alternative 7: 41.2% accurate, 0.9× speedup?

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

                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                            2. Step-by-step derivation
                              1. Applied rewrites64.4%

                                \[\leadsto \mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, 1 \cdot re\right) \]
                            3. Recombined 2 regimes into one program.
                            4. Final simplification48.3%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(im \cdot im, -0.08333333333333333, -0.16666666666666666\right) \cdot re\right) \cdot re\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, re\right)\\ \end{array} \]
                            5. Add Preprocessing

                            Alternative 8: 41.2% accurate, 0.9× speedup?

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

                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites64.4%

                                          \[\leadsto \mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, 1 \cdot re\right) \]
                                      3. Recombined 2 regimes into one program.
                                      4. Final simplification48.4%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(\left(\left(im \cdot im\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, re\right)\\ \end{array} \]
                                      5. Add Preprocessing

                                      Alternative 9: 39.8% accurate, 0.9× speedup?

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

                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                                                2. Step-by-step derivation
                                                  1. Applied rewrites64.4%

                                                    \[\leadsto \mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, 1 \cdot re\right) \]
                                                3. Recombined 2 regimes into one program.
                                                4. Final simplification46.5%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot re\right) \cdot re\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot im\right) \cdot im, re, re\right)\\ \end{array} \]
                                                5. Add Preprocessing

                                                Alternative 10: 39.8% accurate, 0.9× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot re\right) \cdot re\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot re\\ \end{array} \end{array} \]
                                                (FPCore (re im)
                                                 :precision binary64
                                                 (if (<= (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))) -0.1)
                                                   (* (* (* -0.16666666666666666 re) re) re)
                                                   (* (fma (* im im) 0.5 1.0) re)))
                                                double code(double re, double im) {
                                                	double tmp;
                                                	if (((0.5 * sin(re)) * (exp(-im) + exp(im))) <= -0.1) {
                                                		tmp = ((-0.16666666666666666 * re) * re) * re;
                                                	} else {
                                                		tmp = fma((im * im), 0.5, 1.0) * re;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(re, im)
                                                	tmp = 0.0
                                                	if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) <= -0.1)
                                                		tmp = Float64(Float64(Float64(-0.16666666666666666 * re) * re) * re);
                                                	else
                                                		tmp = Float64(fma(Float64(im * im), 0.5, 1.0) * re);
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.1], N[(N[(N[(-0.16666666666666666 * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * re), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\
                                                \;\;\;\;\left(\left(-0.16666666666666666 \cdot re\right) \cdot re\right) \cdot re\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot re\\
                                                
                                                
                                                \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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.10000000000000001

                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        if -0.10000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)))

                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                                                        8. Recombined 2 regimes into one program.
                                                        9. Final simplification46.5%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.1:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot re\right) \cdot re\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot re\\ \end{array} \]
                                                        10. Add Preprocessing

                                                        Alternative 11: 39.8% accurate, 0.9× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot 0.5\right) \cdot re\\ \end{array} \end{array} \]
                                                        (FPCore (re im)
                                                         :precision binary64
                                                         (if (<= (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))) 0.5)
                                                           (* (fma -0.16666666666666666 (* re re) 1.0) re)
                                                           (* (* (* im im) 0.5) re)))
                                                        double code(double re, double im) {
                                                        	double tmp;
                                                        	if (((0.5 * sin(re)) * (exp(-im) + exp(im))) <= 0.5) {
                                                        		tmp = fma(-0.16666666666666666, (re * re), 1.0) * re;
                                                        	} else {
                                                        		tmp = ((im * im) * 0.5) * re;
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(re, im)
                                                        	tmp = 0.0
                                                        	if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) <= 0.5)
                                                        		tmp = Float64(fma(-0.16666666666666666, Float64(re * re), 1.0) * re);
                                                        	else
                                                        		tmp = Float64(Float64(Float64(im * im) * 0.5) * re);
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], N[(N[(-0.16666666666666666 * N[(re * re), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision] * re), $MachinePrecision]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.5:\\
                                                        \;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;\left(\left(im \cdot im\right) \cdot 0.5\right) \cdot re\\
                                                        
                                                        
                                                        \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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.5

                                                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
                                                            10. lower-sin.f6480.9

                                                              \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                          5. Applied rewrites80.9%

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

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

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

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

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

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

                                                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                  \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                              5. Applied rewrites65.6%

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

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

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

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

                                                                    \[\leadsto \left(\left(im \cdot im\right) \cdot 0.5\right) \cdot re \]
                                                                4. Recombined 2 regimes into one program.
                                                                5. Final simplification46.6%

                                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot 0.5\right) \cdot re\\ \end{array} \]
                                                                6. Add Preprocessing

                                                                Alternative 12: 100.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    \[\leadsto \left(\color{blue}{\left(2 \cdot \cosh im\right)} \cdot \sin re\right) \cdot \frac{1}{2} \]
                                                                  16. lower-cosh.f64100.0

                                                                    \[\leadsto \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \sin re\right) \cdot 0.5 \]
                                                                4. Applied rewrites100.0%

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

                                                                Alternative 13: 57.5% accurate, 1.9× speedup?

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

                                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
                                                                    15. lower-sinh.f6455.6

                                                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
                                                                    16. lift--.f64N/A

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

                                                                      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
                                                                    18. lower-neg.f6455.6

                                                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
                                                                  4. Applied rewrites55.6%

                                                                    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
                                                                  5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
                                                                    14. lower-*.f6491.2

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
                                                                    7. lower-*.f6469.6

                                                                      \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
                                                                  10. Applied rewrites69.6%

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

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

                                                                  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                  5. Applied rewrites77.1%

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

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

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

                                                                  Alternative 14: 85.7% accurate, 2.0× speedup?

                                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00132:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 7.6 \cdot 10^{+49}:\\ \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \end{array} \]
                                                                  (FPCore (re im)
                                                                   :precision binary64
                                                                   (if (<= im 0.00132)
                                                                     (* (fma (* 0.5 im) im 1.0) (sin re))
                                                                     (if (<= im 7.6e+49)
                                                                       (*
                                                                        (* (* 2.0 (cosh im)) (* (fma -0.16666666666666666 (* re re) 1.0) re))
                                                                        0.5)
                                                                       (*
                                                                        (* 0.5 (sin re))
                                                                        (fma
                                                                         (fma
                                                                          (fma 0.002777777777777778 (* im im) 0.08333333333333333)
                                                                          (* im im)
                                                                          1.0)
                                                                         (* im im)
                                                                         2.0)))))
                                                                  double code(double re, double im) {
                                                                  	double tmp;
                                                                  	if (im <= 0.00132) {
                                                                  		tmp = fma((0.5 * im), im, 1.0) * sin(re);
                                                                  	} else if (im <= 7.6e+49) {
                                                                  		tmp = ((2.0 * cosh(im)) * (fma(-0.16666666666666666, (re * re), 1.0) * re)) * 0.5;
                                                                  	} else {
                                                                  		tmp = (0.5 * sin(re)) * fma(fma(fma(0.002777777777777778, (im * im), 0.08333333333333333), (im * im), 1.0), (im * im), 2.0);
                                                                  	}
                                                                  	return tmp;
                                                                  }
                                                                  
                                                                  function code(re, im)
                                                                  	tmp = 0.0
                                                                  	if (im <= 0.00132)
                                                                  		tmp = Float64(fma(Float64(0.5 * im), im, 1.0) * sin(re));
                                                                  	elseif (im <= 7.6e+49)
                                                                  		tmp = Float64(Float64(Float64(2.0 * cosh(im)) * Float64(fma(-0.16666666666666666, Float64(re * re), 1.0) * re)) * 0.5);
                                                                  	else
                                                                  		tmp = Float64(Float64(0.5 * sin(re)) * fma(fma(fma(0.002777777777777778, Float64(im * im), 0.08333333333333333), Float64(im * im), 1.0), Float64(im * im), 2.0));
                                                                  	end
                                                                  	return tmp
                                                                  end
                                                                  
                                                                  code[re_, im_] := If[LessEqual[im, 0.00132], N[(N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.6e+49], N[(N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(N[(-0.16666666666666666 * N[(re * re), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(0.002777777777777778 * N[(im * im), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                                  
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \begin{array}{l}
                                                                  \mathbf{if}\;im \leq 0.00132:\\
                                                                  \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\
                                                                  
                                                                  \mathbf{elif}\;im \leq 7.6 \cdot 10^{+49}:\\
                                                                  \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\
                                                                  
                                                                  \mathbf{else}:\\
                                                                  \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)\\
                                                                  
                                                                  
                                                                  \end{array}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Split input into 3 regimes
                                                                  2. if im < 0.00132

                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                    5. Applied rewrites86.3%

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

                                                                    if 0.00132 < im < 7.5999999999999997e49

                                                                    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \left(\color{blue}{\left(2 \cdot \cosh im\right)} \cdot \sin re\right) \cdot \frac{1}{2} \]
                                                                      16. lower-cosh.f6499.9

                                                                        \[\leadsto \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \sin re\right) \cdot 0.5 \]
                                                                    4. Applied rewrites99.9%

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

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

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

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

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

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

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

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

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

                                                                    if 7.5999999999999997e49 < im

                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
                                                                      15. lower-sinh.f640.0

                                                                        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
                                                                      16. lift--.f64N/A

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

                                                                        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
                                                                      18. lower-neg.f640.0

                                                                        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
                                                                    4. Applied rewrites0.0%

                                                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
                                                                    5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
                                                                      14. lower-*.f6498.1

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

                                                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right)} \]
                                                                  3. Recombined 3 regimes into one program.
                                                                  4. Add Preprocessing

                                                                  Alternative 15: 56.9% accurate, 2.0× speedup?

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

                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
                                                                      10. lower-sin.f6468.0

                                                                        \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                    5. Applied rewrites68.0%

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

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

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

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

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

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

                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
                                                                          15. lower-sinh.f6459.6

                                                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
                                                                          16. lift--.f64N/A

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
                                                                          18. lower-neg.f6459.6

                                                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
                                                                        4. Applied rewrites59.6%

                                                                          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
                                                                        5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
                                                                          14. lower-*.f6491.7

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

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

                                                                          \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{360}, im \cdot im, \frac{1}{12}\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
                                                                        9. Step-by-step derivation
                                                                          1. lower-*.f6472.2

                                                                            \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), im \cdot im, 1\right), im \cdot im, 2\right) \]
                                                                        10. Applied rewrites72.2%

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

                                                                      Alternative 16: 85.2% accurate, 2.2× speedup?

                                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00132:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+76}:\\ \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, im \cdot im, 1\right), im \cdot im, 2\right)\\ \end{array} \end{array} \]
                                                                      (FPCore (re im)
                                                                       :precision binary64
                                                                       (if (<= im 0.00132)
                                                                         (* (fma (* 0.5 im) im 1.0) (sin re))
                                                                         (if (<= im 2.75e+76)
                                                                           (*
                                                                            (* (* 2.0 (cosh im)) (* (fma -0.16666666666666666 (* re re) 1.0) re))
                                                                            0.5)
                                                                           (*
                                                                            (* 0.5 (sin re))
                                                                            (fma (fma 0.08333333333333333 (* im im) 1.0) (* im im) 2.0)))))
                                                                      double code(double re, double im) {
                                                                      	double tmp;
                                                                      	if (im <= 0.00132) {
                                                                      		tmp = fma((0.5 * im), im, 1.0) * sin(re);
                                                                      	} else if (im <= 2.75e+76) {
                                                                      		tmp = ((2.0 * cosh(im)) * (fma(-0.16666666666666666, (re * re), 1.0) * re)) * 0.5;
                                                                      	} else {
                                                                      		tmp = (0.5 * sin(re)) * fma(fma(0.08333333333333333, (im * im), 1.0), (im * im), 2.0);
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      function code(re, im)
                                                                      	tmp = 0.0
                                                                      	if (im <= 0.00132)
                                                                      		tmp = Float64(fma(Float64(0.5 * im), im, 1.0) * sin(re));
                                                                      	elseif (im <= 2.75e+76)
                                                                      		tmp = Float64(Float64(Float64(2.0 * cosh(im)) * Float64(fma(-0.16666666666666666, Float64(re * re), 1.0) * re)) * 0.5);
                                                                      	else
                                                                      		tmp = Float64(Float64(0.5 * sin(re)) * fma(fma(0.08333333333333333, Float64(im * im), 1.0), Float64(im * im), 2.0));
                                                                      	end
                                                                      	return tmp
                                                                      end
                                                                      
                                                                      code[re_, im_] := If[LessEqual[im, 0.00132], N[(N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.75e+76], N[(N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(N[(-0.16666666666666666 * N[(re * re), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(0.08333333333333333 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                                      
                                                                      \begin{array}{l}
                                                                      
                                                                      \\
                                                                      \begin{array}{l}
                                                                      \mathbf{if}\;im \leq 0.00132:\\
                                                                      \;\;\;\;\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re\\
                                                                      
                                                                      \mathbf{elif}\;im \leq 2.75 \cdot 10^{+76}:\\
                                                                      \;\;\;\;\left(\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.16666666666666666, re \cdot re, 1\right) \cdot re\right)\right) \cdot 0.5\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, im \cdot im, 1\right), im \cdot im, 2\right)\\
                                                                      
                                                                      
                                                                      \end{array}
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Split input into 3 regimes
                                                                      2. if im < 0.00132

                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                        5. Applied rewrites86.3%

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

                                                                        if 0.00132 < im < 2.75e76

                                                                        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \left(\color{blue}{\left(2 \cdot \cosh im\right)} \cdot \sin re\right) \cdot \frac{1}{2} \]
                                                                          16. lower-cosh.f6499.9

                                                                            \[\leadsto \left(\left(2 \cdot \color{blue}{\cosh im}\right) \cdot \sin re\right) \cdot 0.5 \]
                                                                        4. Applied rewrites99.9%

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

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

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

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

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

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

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

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

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

                                                                        if 2.75e76 < im

                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \color{blue}{\sinh im} \cdot \sinh im}{e^{0 - im}}\right) \]
                                                                          15. lower-sinh.f640.0

                                                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \color{blue}{\sinh im}}{e^{0 - im}}\right) \]
                                                                          16. lift--.f64N/A

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{\mathsf{neg}\left(im\right)}}}\right) \]
                                                                          18. lower-neg.f640.0

                                                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{\color{blue}{-im}}}\right) \]
                                                                        4. Applied rewrites0.0%

                                                                          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{\frac{\cosh im \cdot \cosh im - \sinh im \cdot \sinh im}{e^{-im}}}\right) \]
                                                                        5. Taylor expanded in im around 0

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, im \cdot im, 1\right), \color{blue}{im \cdot im}, 2\right) \]
                                                                          9. lower-*.f6495.7

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

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

                                                                      Alternative 17: 51.8% accurate, 2.2× speedup?

                                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(re \cdot im\right) \cdot re, -0.08333333333333333, 0.5 \cdot im\right) \cdot re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\left(im \cdot im\right) \cdot im}{im}, 0.5, 1\right) \cdot re\\ \end{array} \end{array} \]
                                                                      (FPCore (re im)
                                                                       :precision binary64
                                                                       (if (<= (* 0.5 (sin re)) -0.02)
                                                                         (* (* (fma (* (* re im) re) -0.08333333333333333 (* 0.5 im)) re) im)
                                                                         (* (fma (/ (* (* im im) im) im) 0.5 1.0) re)))
                                                                      double code(double re, double im) {
                                                                      	double tmp;
                                                                      	if ((0.5 * sin(re)) <= -0.02) {
                                                                      		tmp = (fma(((re * im) * re), -0.08333333333333333, (0.5 * im)) * re) * im;
                                                                      	} else {
                                                                      		tmp = fma((((im * im) * im) / im), 0.5, 1.0) * re;
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      function code(re, im)
                                                                      	tmp = 0.0
                                                                      	if (Float64(0.5 * sin(re)) <= -0.02)
                                                                      		tmp = Float64(Float64(fma(Float64(Float64(re * im) * re), -0.08333333333333333, Float64(0.5 * im)) * re) * im);
                                                                      	else
                                                                      		tmp = Float64(fma(Float64(Float64(Float64(im * im) * im) / im), 0.5, 1.0) * re);
                                                                      	end
                                                                      	return tmp
                                                                      end
                                                                      
                                                                      code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(N[(N[(N[(re * im), $MachinePrecision] * re), $MachinePrecision] * -0.08333333333333333 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision], N[(N[(N[(N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision] / im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * re), $MachinePrecision]]
                                                                      
                                                                      \begin{array}{l}
                                                                      
                                                                      \\
                                                                      \begin{array}{l}
                                                                      \mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\
                                                                      \;\;\;\;\left(\mathsf{fma}\left(\left(re \cdot im\right) \cdot re, -0.08333333333333333, 0.5 \cdot im\right) \cdot re\right) \cdot im\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;\mathsf{fma}\left(\frac{\left(im \cdot im\right) \cdot im}{im}, 0.5, 1\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.0200000000000000004

                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
                                                                          10. lower-sin.f6468.0

                                                                            \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                        5. Applied rewrites68.0%

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

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

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

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

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

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

                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                                                                              2. Step-by-step derivation
                                                                                1. Applied rewrites65.8%

                                                                                  \[\leadsto \mathsf{fma}\left(\frac{\left(im \cdot \left(-im\right)\right) \cdot \left(-im\right)}{im}, 0.5, 1\right) \cdot re \]
                                                                              3. Recombined 2 regimes into one program.
                                                                              4. Final simplification54.6%

                                                                                \[\leadsto \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(re \cdot im\right) \cdot re, -0.08333333333333333, 0.5 \cdot im\right) \cdot re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\left(im \cdot im\right) \cdot im}{im}, 0.5, 1\right) \cdot re\\ \end{array} \]
                                                                              5. Add Preprocessing

                                                                              Alternative 18: 17.5% accurate, 2.5× speedup?

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

                                                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                                    \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                                5. Applied rewrites74.1%

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

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

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

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

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

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

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

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

                                                                                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                                          \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                                      5. Applied rewrites78.3%

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

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

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

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

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

                                                                                        Alternative 19: 24.7% accurate, 19.8× speedup?

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

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

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

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

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

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

                                                                                            \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
                                                                                          5. *-commutativeN/A

                                                                                            \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
                                                                                          6. lower-*.f64N/A

                                                                                            \[\leadsto \color{blue}{\left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \cdot \sin re} \]
                                                                                          7. *-commutativeN/A

                                                                                            \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
                                                                                          8. lower-fma.f64N/A

                                                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2} \cdot im, im, 1\right)} \cdot \sin re \]
                                                                                          9. lower-*.f64N/A

                                                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
                                                                                          10. lower-sin.f6476.3

                                                                                            \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                                        5. Applied rewrites76.3%

                                                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re} \]
                                                                                        6. Taylor expanded in re around 0

                                                                                          \[\leadsto re \cdot \color{blue}{\left(1 + \frac{1}{2} \cdot {im}^{2}\right)} \]
                                                                                        7. Step-by-step derivation
                                                                                          1. Applied rewrites52.2%

                                                                                            \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \color{blue}{re} \]
                                                                                          2. Taylor expanded in im around inf

                                                                                            \[\leadsto \left(\frac{1}{2} \cdot {im}^{2}\right) \cdot re \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites23.8%

                                                                                              \[\leadsto \left(\left(im \cdot im\right) \cdot 0.5\right) \cdot re \]
                                                                                            2. Add Preprocessing

                                                                                            Alternative 20: 19.2% accurate, 19.8× speedup?

                                                                                            \[\begin{array}{l} \\ \left(\left(re \cdot im\right) \cdot 0.5\right) \cdot im \end{array} \]
                                                                                            (FPCore (re im) :precision binary64 (* (* (* re im) 0.5) im))
                                                                                            double code(double re, double im) {
                                                                                            	return ((re * im) * 0.5) * 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) * 0.5d0) * im
                                                                                            end function
                                                                                            
                                                                                            public static double code(double re, double im) {
                                                                                            	return ((re * im) * 0.5) * im;
                                                                                            }
                                                                                            
                                                                                            def code(re, im):
                                                                                            	return ((re * im) * 0.5) * im
                                                                                            
                                                                                            function code(re, im)
                                                                                            	return Float64(Float64(Float64(re * im) * 0.5) * im)
                                                                                            end
                                                                                            
                                                                                            function tmp = code(re, im)
                                                                                            	tmp = ((re * im) * 0.5) * im;
                                                                                            end
                                                                                            
                                                                                            code[re_, im_] := N[(N[(N[(re * im), $MachinePrecision] * 0.5), $MachinePrecision] * im), $MachinePrecision]
                                                                                            
                                                                                            \begin{array}{l}
                                                                                            
                                                                                            \\
                                                                                            \left(\left(re \cdot im\right) \cdot 0.5\right) \cdot im
                                                                                            \end{array}
                                                                                            
                                                                                            Derivation
                                                                                            1. Initial program 100.0%

                                                                                              \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
                                                                                            2. Add Preprocessing
                                                                                            3. Taylor expanded in im around 0

                                                                                              \[\leadsto \color{blue}{\sin re + \frac{1}{2} \cdot \left({im}^{2} \cdot \sin re\right)} \]
                                                                                            4. Step-by-step derivation
                                                                                              1. associate-*r*N/A

                                                                                                \[\leadsto \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot \sin re} \]
                                                                                              2. distribute-rgt1-inN/A

                                                                                                \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
                                                                                              3. unpow2N/A

                                                                                                \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \cdot \sin re \]
                                                                                              4. associate-*r*N/A

                                                                                                \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
                                                                                              5. *-commutativeN/A

                                                                                                \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
                                                                                              6. lower-*.f64N/A

                                                                                                \[\leadsto \color{blue}{\left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \cdot \sin re} \]
                                                                                              7. *-commutativeN/A

                                                                                                \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
                                                                                              8. lower-fma.f64N/A

                                                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2} \cdot im, im, 1\right)} \cdot \sin re \]
                                                                                              9. lower-*.f64N/A

                                                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot im}, im, 1\right) \cdot \sin re \]
                                                                                              10. lower-sin.f6476.3

                                                                                                \[\leadsto \mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \color{blue}{\sin re} \]
                                                                                            5. Applied rewrites76.3%

                                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(0.5 \cdot im, im, 1\right) \cdot \sin re} \]
                                                                                            6. Taylor expanded in im around inf

                                                                                              \[\leadsto \frac{1}{2} \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)} \]
                                                                                            7. Step-by-step derivation
                                                                                              1. Applied rewrites18.5%

                                                                                                \[\leadsto \left(\left(\sin re \cdot 0.5\right) \cdot im\right) \cdot \color{blue}{im} \]
                                                                                              2. Taylor expanded in re around 0

                                                                                                \[\leadsto \left(\frac{1}{2} \cdot \left(im \cdot re\right)\right) \cdot im \]
                                                                                              3. Step-by-step derivation
                                                                                                1. Applied rewrites18.3%

                                                                                                  \[\leadsto \left(\left(re \cdot im\right) \cdot 0.5\right) \cdot im \]
                                                                                                2. Add Preprocessing

                                                                                                Reproduce

                                                                                                ?
                                                                                                herbie shell --seed 2025015 
                                                                                                (FPCore (re im)
                                                                                                  :name "math.sin on complex, real part"
                                                                                                  :precision binary64
                                                                                                  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))