math.cos on complex, imaginary part

Percentage Accurate: 65.0% → 99.6%
Time: 8.3s
Alternatives: 27
Speedup: 2.6×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 27 alternatives:

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

Initial Program: 65.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 99.6% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq -2.95:\\
\;\;\;\;t\_0 \cdot \left(e^{-im} - 1\right)\\

\mathbf{elif}\;im \leq 3:\\
\;\;\;\;\mathsf{fma}\left(\sin re \cdot \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), im \cdot im, -\sin re\right) \cdot im\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.9500000000000002

    1. Initial program 100.0%

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

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

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

      if -2.9500000000000002 < im < 3

      1. Initial program 32.5%

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

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

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

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

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

      if 3 < im

      1. Initial program 100.0%

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

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

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

      Alternative 2: 99.6% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq -2.95:\\ \;\;\;\;t\_0 \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 3:\\ \;\;\;\;t\_0 \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (let* ((t_0 (* 0.5 (sin re))))
         (if (<= im -2.95)
           (* t_0 (- (exp (- im)) 1.0))
           (if (<= im 3.0)
             (*
              t_0
              (*
               (-
                (*
                 (* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) im)
                 im)
                2.0)
               im))
             (* t_0 (- 1.0 (exp im)))))))
      double code(double re, double im) {
      	double t_0 = 0.5 * sin(re);
      	double tmp;
      	if (im <= -2.95) {
      		tmp = t_0 * (exp(-im) - 1.0);
      	} else if (im <= 3.0) {
      		tmp = t_0 * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
      	} else {
      		tmp = t_0 * (1.0 - exp(im));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(re, im)
      use fmin_fmax_functions
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: t_0
          real(8) :: tmp
          t_0 = 0.5d0 * sin(re)
          if (im <= (-2.95d0)) then
              tmp = t_0 * (exp(-im) - 1.0d0)
          else if (im <= 3.0d0) then
              tmp = t_0 * (((((((-0.016666666666666666d0) * (im * im)) - 0.3333333333333333d0) * im) * im) - 2.0d0) * im)
          else
              tmp = t_0 * (1.0d0 - exp(im))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double t_0 = 0.5 * Math.sin(re);
      	double tmp;
      	if (im <= -2.95) {
      		tmp = t_0 * (Math.exp(-im) - 1.0);
      	} else if (im <= 3.0) {
      		tmp = t_0 * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
      	} else {
      		tmp = t_0 * (1.0 - Math.exp(im));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	t_0 = 0.5 * math.sin(re)
      	tmp = 0
      	if im <= -2.95:
      		tmp = t_0 * (math.exp(-im) - 1.0)
      	elif im <= 3.0:
      		tmp = t_0 * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im)
      	else:
      		tmp = t_0 * (1.0 - math.exp(im))
      	return tmp
      
      function code(re, im)
      	t_0 = Float64(0.5 * sin(re))
      	tmp = 0.0
      	if (im <= -2.95)
      		tmp = Float64(t_0 * Float64(exp(Float64(-im)) - 1.0));
      	elseif (im <= 3.0)
      		tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im));
      	else
      		tmp = Float64(t_0 * Float64(1.0 - exp(im)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	t_0 = 0.5 * sin(re);
      	tmp = 0.0;
      	if (im <= -2.95)
      		tmp = t_0 * (exp(-im) - 1.0);
      	elseif (im <= 3.0)
      		tmp = t_0 * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
      	else
      		tmp = t_0 * (1.0 - exp(im));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.95], N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.0], N[(t$95$0 * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 0.5 \cdot \sin re\\
      \mathbf{if}\;im \leq -2.95:\\
      \;\;\;\;t\_0 \cdot \left(e^{-im} - 1\right)\\
      
      \mathbf{elif}\;im \leq 3:\\
      \;\;\;\;t\_0 \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if im < -2.9500000000000002

        1. Initial program 100.0%

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

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

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

          if -2.9500000000000002 < im < 3

          1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
          5. Applied rewrites99.8%

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

          if 3 < im

          1. Initial program 100.0%

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

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

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

          Alternative 3: 96.4% accurate, 1.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 3.75:\\ \;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (let* ((t_0 (* 0.5 (sin re))))
             (if (<= im 3.75)
               (*
                t_0
                (*
                 (-
                  (*
                   (-
                    (*
                     (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
                     im)
                    0.3333333333333333)
                   (* im im))
                  2.0)
                 im))
               (* t_0 (- 1.0 (exp im))))))
          double code(double re, double im) {
          	double t_0 = 0.5 * sin(re);
          	double tmp;
          	if (im <= 3.75) {
          		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
          	} else {
          		tmp = t_0 * (1.0 - exp(im));
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(re, im)
          use fmin_fmax_functions
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              real(8) :: t_0
              real(8) :: tmp
              t_0 = 0.5d0 * sin(re)
              if (im <= 3.75d0) then
                  tmp = t_0 * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
              else
                  tmp = t_0 * (1.0d0 - exp(im))
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double t_0 = 0.5 * Math.sin(re);
          	double tmp;
          	if (im <= 3.75) {
          		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
          	} else {
          		tmp = t_0 * (1.0 - Math.exp(im));
          	}
          	return tmp;
          }
          
          def code(re, im):
          	t_0 = 0.5 * math.sin(re)
          	tmp = 0
          	if im <= 3.75:
          		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im)
          	else:
          		tmp = t_0 * (1.0 - math.exp(im))
          	return tmp
          
          function code(re, im)
          	t_0 = Float64(0.5 * sin(re))
          	tmp = 0.0
          	if (im <= 3.75)
          		tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
          	else
          		tmp = Float64(t_0 * Float64(1.0 - exp(im)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	t_0 = 0.5 * sin(re);
          	tmp = 0.0;
          	if (im <= 3.75)
          		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
          	else
          		tmp = t_0 * (1.0 - exp(im));
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.75], N[(t$95$0 * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := 0.5 \cdot \sin re\\
          \mathbf{if}\;im \leq 3.75:\\
          \;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if im < 3.75

            1. Initial program 54.2%

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

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

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

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

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

            if 3.75 < im

            1. Initial program 100.0%

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

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

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

            Alternative 4: 57.9% accurate, 1.6× speedup?

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

              1. Initial program 68.0%

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

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

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

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

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

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

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

                  \[\leadsto \left(\left(\frac{1}{2} + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{240} + \frac{-1}{10080} \cdot {re}^{2}\right) - \frac{1}{12}\right)\right) \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              8. Applied rewrites60.2%

                \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(-9.92063492063492 \cdot 10^{-5}, re \cdot re, 0.004166666666666667\right) \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              9. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                2. lift--.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                3. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                4. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                5. lift--.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                6. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                7. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                8. lift-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                9. associate-*r*N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
                10. lower-*.f64N/A

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{10080}, re \cdot re, \frac{1}{240}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
              10. Applied rewrites60.2%

                \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-9.92063492063492 \cdot 10^{-5}, re \cdot re, 0.004166666666666667\right) \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(im \cdot im\right) \cdot \left(\left(-0.0003968253968253968 \cdot im\right) \cdot im - 0.016666666666666666\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]

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

              1. Initial program 63.8%

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

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

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

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

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

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

                  \[\leadsto \left(-\sin re\right) \cdot im \]
                6. lift-sin.f6444.6

                  \[\leadsto \left(-\sin re\right) \cdot im \]
              5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                15. mul-1-negN/A

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                16. lower-neg.f6424.1

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

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

            Alternative 5: 57.8% accurate, 1.6× speedup?

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

              1. Initial program 68.0%

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

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

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

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

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

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

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

                  \[\leadsto \left(\left(\frac{1}{2} + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{240} + \frac{-1}{10080} \cdot {re}^{2}\right) - \frac{1}{12}\right)\right) \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              8. Applied rewrites60.2%

                \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(-9.92063492063492 \cdot 10^{-5}, re \cdot re, 0.004166666666666667\right) \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              9. Taylor expanded in re around inf

                \[\leadsto \left(\mathsf{fma}\left(\left(\frac{-1}{10080} \cdot {re}^{2}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              10. Step-by-step derivation
                1. *-commutativeN/A

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

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

                  \[\leadsto \left(\mathsf{fma}\left(\left(\left(re \cdot re\right) \cdot \frac{-1}{10080}\right) \cdot \left(re \cdot re\right) - \frac{1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                4. lift-*.f6460.2

                  \[\leadsto \left(\mathsf{fma}\left(\left(\left(re \cdot re\right) \cdot -9.92063492063492 \cdot 10^{-5}\right) \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              11. Applied rewrites60.2%

                \[\leadsto \left(\mathsf{fma}\left(\left(\left(re \cdot re\right) \cdot -9.92063492063492 \cdot 10^{-5}\right) \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]

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

              1. Initial program 63.8%

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

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

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

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

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

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

                  \[\leadsto \left(-\sin re\right) \cdot im \]
                6. lift-sin.f6444.6

                  \[\leadsto \left(-\sin re\right) \cdot im \]
              5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                15. mul-1-negN/A

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                16. lower-neg.f6424.1

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

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

            Alternative 6: 57.8% accurate, 1.8× speedup?

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

              1. Initial program 68.0%

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

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

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

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

                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
              6. 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 \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              7. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

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

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

                  \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                7. lower-*.f6459.9

                  \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              8. Applied rewrites59.9%

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

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

              1. Initial program 63.8%

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

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

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

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

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

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

                  \[\leadsto \left(-\sin re\right) \cdot im \]
                6. lift-sin.f6444.6

                  \[\leadsto \left(-\sin re\right) \cdot im \]
              5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                15. mul-1-negN/A

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                16. lower-neg.f6424.1

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

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

            Alternative 7: 57.8% accurate, 1.8× speedup?

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

              1. Initial program 68.0%

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

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

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
              7. Step-by-step derivation
                1. Applied rewrites86.9%

                  \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                  7. lift-*.f6457.9

                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                4. Applied rewrites57.9%

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

                  \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot {im}^{2}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                6. Step-by-step derivation
                  1. pow2N/A

                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                  2. associate-*r*N/A

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

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

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

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

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

                1. Initial program 63.8%

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

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

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

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

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

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

                    \[\leadsto \left(-\sin re\right) \cdot im \]
                  6. lift-sin.f6444.6

                    \[\leadsto \left(-\sin re\right) \cdot im \]
                5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                  15. mul-1-negN/A

                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                  16. lower-neg.f6424.1

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

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

              Alternative 8: 95.5% accurate, 1.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 7.8 \lor \neg \left(im \leq 3.35 \cdot 10^{+44}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
              (FPCore (re im)
               :precision binary64
               (if (or (<= im 7.8) (not (<= im 3.35e+44)))
                 (*
                  (* 0.5 (sin re))
                  (*
                   (-
                    (*
                     (-
                      (*
                       (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
                       im)
                      0.3333333333333333)
                     (* im im))
                    2.0)
                   im))
                 (* (* 0.5 re) (- 1.0 (exp im)))))
              double code(double re, double im) {
              	double tmp;
              	if ((im <= 7.8) || !(im <= 3.35e+44)) {
              		tmp = (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
              	} else {
              		tmp = (0.5 * re) * (1.0 - exp(im));
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(re, im)
              use fmin_fmax_functions
                  real(8), intent (in) :: re
                  real(8), intent (in) :: im
                  real(8) :: tmp
                  if ((im <= 7.8d0) .or. (.not. (im <= 3.35d+44))) then
                      tmp = (0.5d0 * sin(re)) * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
                  else
                      tmp = (0.5d0 * re) * (1.0d0 - exp(im))
                  end if
                  code = tmp
              end function
              
              public static double code(double re, double im) {
              	double tmp;
              	if ((im <= 7.8) || !(im <= 3.35e+44)) {
              		tmp = (0.5 * Math.sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
              	} else {
              		tmp = (0.5 * re) * (1.0 - Math.exp(im));
              	}
              	return tmp;
              }
              
              def code(re, im):
              	tmp = 0
              	if (im <= 7.8) or not (im <= 3.35e+44):
              		tmp = (0.5 * math.sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im)
              	else:
              		tmp = (0.5 * re) * (1.0 - math.exp(im))
              	return tmp
              
              function code(re, im)
              	tmp = 0.0
              	if ((im <= 7.8) || !(im <= 3.35e+44))
              		tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
              	else
              		tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(re, im)
              	tmp = 0.0;
              	if ((im <= 7.8) || ~((im <= 3.35e+44)))
              		tmp = (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
              	else
              		tmp = (0.5 * re) * (1.0 - exp(im));
              	end
              	tmp_2 = tmp;
              end
              
              code[re_, im_] := If[Or[LessEqual[im, 7.8], N[Not[LessEqual[im, 3.35e+44]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;im \leq 7.8 \lor \neg \left(im \leq 3.35 \cdot 10^{+44}\right):\\
              \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if im < 7.79999999999999982 or 3.35000000000000018e44 < im

                1. Initial program 64.6%

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

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

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

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

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

                if 7.79999999999999982 < im < 3.35000000000000018e44

                1. Initial program 100.0%

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

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

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

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

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 7.8 \lor \neg \left(im \leq 3.35 \cdot 10^{+44}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 9: 97.1% accurate, 1.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{if}\;im \leq -1.04 \cdot 10^{+65}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq -10:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 7.2 \lor \neg \left(im \leq 9.2 \cdot 10^{+61}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
                  (FPCore (re im)
                   :precision binary64
                   (let* ((t_0
                           (*
                            (* 0.5 (sin re))
                            (*
                             (-
                              (*
                               (* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) im)
                               im)
                              2.0)
                             im))))
                     (if (<= im -1.04e+65)
                       t_0
                       (if (<= im -10.0)
                         (* (* re 0.5) (- (exp (- im)) 1.0))
                         (if (or (<= im 7.2) (not (<= im 9.2e+61)))
                           t_0
                           (* (* 0.5 re) (- 1.0 (exp im))))))))
                  double code(double re, double im) {
                  	double t_0 = (0.5 * sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
                  	double tmp;
                  	if (im <= -1.04e+65) {
                  		tmp = t_0;
                  	} else if (im <= -10.0) {
                  		tmp = (re * 0.5) * (exp(-im) - 1.0);
                  	} else if ((im <= 7.2) || !(im <= 9.2e+61)) {
                  		tmp = t_0;
                  	} else {
                  		tmp = (0.5 * re) * (1.0 - exp(im));
                  	}
                  	return tmp;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(re, im)
                  use fmin_fmax_functions
                      real(8), intent (in) :: re
                      real(8), intent (in) :: im
                      real(8) :: t_0
                      real(8) :: tmp
                      t_0 = (0.5d0 * sin(re)) * (((((((-0.016666666666666666d0) * (im * im)) - 0.3333333333333333d0) * im) * im) - 2.0d0) * im)
                      if (im <= (-1.04d+65)) then
                          tmp = t_0
                      else if (im <= (-10.0d0)) then
                          tmp = (re * 0.5d0) * (exp(-im) - 1.0d0)
                      else if ((im <= 7.2d0) .or. (.not. (im <= 9.2d+61))) then
                          tmp = t_0
                      else
                          tmp = (0.5d0 * re) * (1.0d0 - exp(im))
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double re, double im) {
                  	double t_0 = (0.5 * Math.sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
                  	double tmp;
                  	if (im <= -1.04e+65) {
                  		tmp = t_0;
                  	} else if (im <= -10.0) {
                  		tmp = (re * 0.5) * (Math.exp(-im) - 1.0);
                  	} else if ((im <= 7.2) || !(im <= 9.2e+61)) {
                  		tmp = t_0;
                  	} else {
                  		tmp = (0.5 * re) * (1.0 - Math.exp(im));
                  	}
                  	return tmp;
                  }
                  
                  def code(re, im):
                  	t_0 = (0.5 * math.sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im)
                  	tmp = 0
                  	if im <= -1.04e+65:
                  		tmp = t_0
                  	elif im <= -10.0:
                  		tmp = (re * 0.5) * (math.exp(-im) - 1.0)
                  	elif (im <= 7.2) or not (im <= 9.2e+61):
                  		tmp = t_0
                  	else:
                  		tmp = (0.5 * re) * (1.0 - math.exp(im))
                  	return tmp
                  
                  function code(re, im)
                  	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im))
                  	tmp = 0.0
                  	if (im <= -1.04e+65)
                  		tmp = t_0;
                  	elseif (im <= -10.0)
                  		tmp = Float64(Float64(re * 0.5) * Float64(exp(Float64(-im)) - 1.0));
                  	elseif ((im <= 7.2) || !(im <= 9.2e+61))
                  		tmp = t_0;
                  	else
                  		tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im)));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(re, im)
                  	t_0 = (0.5 * sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
                  	tmp = 0.0;
                  	if (im <= -1.04e+65)
                  		tmp = t_0;
                  	elseif (im <= -10.0)
                  		tmp = (re * 0.5) * (exp(-im) - 1.0);
                  	elseif ((im <= 7.2) || ~((im <= 9.2e+61)))
                  		tmp = t_0;
                  	else
                  		tmp = (0.5 * re) * (1.0 - exp(im));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.04e+65], t$95$0, If[LessEqual[im, -10.0], N[(N[(re * 0.5), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 7.2], N[Not[LessEqual[im, 9.2e+61]], $MachinePrecision]], t$95$0, N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
                  \mathbf{if}\;im \leq -1.04 \cdot 10^{+65}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;im \leq -10:\\
                  \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\
                  
                  \mathbf{elif}\;im \leq 7.2 \lor \neg \left(im \leq 9.2 \cdot 10^{+61}\right):\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if im < -1.03999999999999999e65 or -10 < im < 7.20000000000000018 or 9.1999999999999998e61 < im

                    1. Initial program 61.8%

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
                      12. lower-*.f6499.5

                        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
                    5. Applied rewrites99.5%

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

                    if -1.03999999999999999e65 < im < -10

                    1. Initial program 100.0%

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

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

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

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

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

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

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

                      if 7.20000000000000018 < im < 9.1999999999999998e61

                      1. Initial program 100.0%

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

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

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

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

                            \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(1 - e^{im}\right) \]
                        4. Recombined 3 regimes into one program.
                        5. Final simplification97.6%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.04 \cdot 10^{+65}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{elif}\;im \leq -10:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 7.2 \lor \neg \left(im \leq 9.2 \cdot 10^{+61}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \]
                        6. Add Preprocessing

                        Alternative 10: 58.3% accurate, 1.9× speedup?

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

                          1. Initial program 48.3%

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

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

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

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

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

                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                          7. Step-by-step derivation
                            1. Applied rewrites87.9%

                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                            2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                            3. Step-by-step derivation
                              1. *-commutativeN/A

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

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

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

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

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

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

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

                              \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                            5. Step-by-step derivation
                              1. lift-fma.f64N/A

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

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

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

                                \[\leadsto \left(\mathsf{fma}\left(re, re \cdot \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                              5. lower-*.f6415.7

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

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

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

                            1. Initial program 75.4%

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

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

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

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

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

                              \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                            7. Step-by-step derivation
                              1. Applied rewrites67.1%

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

                            Alternative 11: 56.5% accurate, 1.9× speedup?

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

                              1. Initial program 68.0%

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

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

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

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

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

                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                              7. Step-by-step derivation
                                1. Applied rewrites86.9%

                                  \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                3. Step-by-step derivation
                                  1. *-commutativeN/A

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

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

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

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

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

                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  7. lift-*.f6457.9

                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                4. Applied rewrites57.9%

                                  \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                5. Step-by-step derivation
                                  1. lift-fma.f64N/A

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

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

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

                                    \[\leadsto \left(\mathsf{fma}\left(re, re \cdot \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  5. lower-*.f6457.9

                                    \[\leadsto \left(\mathsf{fma}\left(re, re \cdot -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                6. Applied rewrites57.9%

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

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

                                1. Initial program 63.8%

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

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

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

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

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

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

                                    \[\leadsto \left(-\sin re\right) \cdot im \]
                                  6. lift-sin.f6444.6

                                    \[\leadsto \left(-\sin re\right) \cdot im \]
                                5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                                  15. mul-1-negN/A

                                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                  16. lower-neg.f6424.1

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

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

                              Alternative 12: 56.6% accurate, 1.9× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\\ \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\ \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot t\_0\\ \end{array} \end{array} \]
                              (FPCore (re im)
                               :precision binary64
                               (let* ((t_0
                                       (*
                                        (-
                                         (*
                                          (- (* (* -0.016666666666666666 im) im) 0.3333333333333333)
                                          (* im im))
                                         2.0)
                                        im)))
                                 (if (<= (* 0.5 (sin re)) -0.005)
                                   (* (* (* (* re re) -0.08333333333333333) re) t_0)
                                   (* (* re 0.5) t_0))))
                              double code(double re, double im) {
                              	double t_0 = (((((-0.016666666666666666 * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im;
                              	double tmp;
                              	if ((0.5 * sin(re)) <= -0.005) {
                              		tmp = (((re * re) * -0.08333333333333333) * re) * t_0;
                              	} else {
                              		tmp = (re * 0.5) * t_0;
                              	}
                              	return tmp;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(re, im)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: re
                                  real(8), intent (in) :: im
                                  real(8) :: t_0
                                  real(8) :: tmp
                                  t_0 = ((((((-0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im
                                  if ((0.5d0 * sin(re)) <= (-0.005d0)) then
                                      tmp = (((re * re) * (-0.08333333333333333d0)) * re) * t_0
                                  else
                                      tmp = (re * 0.5d0) * t_0
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double re, double im) {
                              	double t_0 = (((((-0.016666666666666666 * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im;
                              	double tmp;
                              	if ((0.5 * Math.sin(re)) <= -0.005) {
                              		tmp = (((re * re) * -0.08333333333333333) * re) * t_0;
                              	} else {
                              		tmp = (re * 0.5) * t_0;
                              	}
                              	return tmp;
                              }
                              
                              def code(re, im):
                              	t_0 = (((((-0.016666666666666666 * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im
                              	tmp = 0
                              	if (0.5 * math.sin(re)) <= -0.005:
                              		tmp = (((re * re) * -0.08333333333333333) * re) * t_0
                              	else:
                              		tmp = (re * 0.5) * t_0
                              	return tmp
                              
                              function code(re, im)
                              	t_0 = Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)
                              	tmp = 0.0
                              	if (Float64(0.5 * sin(re)) <= -0.005)
                              		tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * t_0);
                              	else
                              		tmp = Float64(Float64(re * 0.5) * t_0);
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(re, im)
                              	t_0 = (((((-0.016666666666666666 * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im;
                              	tmp = 0.0;
                              	if ((0.5 * sin(re)) <= -0.005)
                              		tmp = (((re * re) * -0.08333333333333333) * re) * t_0;
                              	else
                              		tmp = (re * 0.5) * t_0;
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[(N[(N[(-0.016666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(re * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              t_0 := \left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\\
                              \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
                              \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot t\_0\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\left(re \cdot 0.5\right) \cdot t\_0\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001

                                1. Initial program 48.3%

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

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

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

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

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

                                  \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                7. Step-by-step derivation
                                  1. Applied rewrites87.9%

                                    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  3. Step-by-step derivation
                                    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\left(\left(re \cdot re\right) \cdot \frac{-1}{12}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                    4. lift-*.f6415.7

                                      \[\leadsto \left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  7. Applied rewrites15.7%

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

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

                                  1. Initial program 75.4%

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

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

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

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

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

                                    \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites86.5%

                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                    2. Taylor expanded in re around 0

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

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

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

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

                                  Alternative 13: 95.2% accurate, 2.1× speedup?

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

                                    1. Initial program 100.0%

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

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

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

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

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

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

                                        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\frac{-1}{3} \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                      6. lower-*.f64100.0

                                        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                    5. Applied rewrites100.0%

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

                                    if -4.80000000000000025e110 < im < -6.0999999999999996

                                    1. Initial program 100.0%

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

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

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

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

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

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

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

                                      if -6.0999999999999996 < im < 4.70000000000000018

                                      1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      if 4.70000000000000018 < im < 7.99999999999999982e102

                                      1. Initial program 100.0%

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

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

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

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

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

                                        Alternative 14: 56.6% accurate, 2.1× speedup?

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

                                          1. Initial program 48.3%

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

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

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

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

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

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

                                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\frac{-1}{3} \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                            6. lower-*.f6483.1

                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                          5. Applied rewrites83.1%

                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
                                          6. 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 \left(\left(\frac{-1}{3} \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                          7. Step-by-step derivation
                                            1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                                          1. Initial program 75.4%

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

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

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

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

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

                                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites86.5%

                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                            2. Taylor expanded in re around 0

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

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

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

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

                                          Alternative 15: 53.2% accurate, 2.1× speedup?

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

                                            1. Initial program 68.0%

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

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

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

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

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

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

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

                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                            5. Applied rewrites81.9%

                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
                                            6. 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 \left(\left(\frac{-1}{3} \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                            7. Step-by-step derivation
                                              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                                            1. Initial program 63.8%

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

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

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

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

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

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

                                                \[\leadsto \left(-\sin re\right) \cdot im \]
                                              6. lift-sin.f6444.6

                                                \[\leadsto \left(-\sin re\right) \cdot im \]
                                            5. Applied rewrites44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, -1 \cdot im\right) \cdot re \]
                                              15. mul-1-negN/A

                                                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{-1}{120}, \frac{1}{6} \cdot im\right), re \cdot re, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                              16. lower-neg.f6424.1

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

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

                                          Alternative 16: 55.0% accurate, 2.1× speedup?

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

                                            1. Initial program 48.3%

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

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

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

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

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

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

                                                \[\leadsto \left(-\sin re\right) \cdot im \]
                                              6. lift-sin.f6457.6

                                                \[\leadsto \left(-\sin re\right) \cdot im \]
                                            5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                              10. mul-1-negN/A

                                                \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                              11. lower-neg.f6413.3

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

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

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

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

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

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

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

                                                \[\leadsto \mathsf{fma}\left(re \cdot \left(im \cdot re\right), 0.16666666666666666, -im\right) \cdot re \]
                                            10. Applied rewrites13.3%

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

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

                                            1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                              12. lift-*.f6462.8

                                                \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                            8. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                              13. lift--.f6462.8

                                                \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                            11. Applied rewrites62.8%

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

                                          Alternative 17: 92.7% accurate, 2.2× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im\\ \mathbf{if}\;im \leq -8.2 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq -6.1:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 4.7 \lor \neg \left(im \leq 1.9 \cdot 10^{+129}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \end{array} \]
                                          (FPCore (re im)
                                           :precision binary64
                                           (let* ((t_0 (* (* (sin re) (fma (* -0.16666666666666666 im) im -1.0)) im)))
                                             (if (<= im -8.2e+113)
                                               t_0
                                               (if (<= im -6.1)
                                                 (* (* re 0.5) (- (exp (- im)) 1.0))
                                                 (if (or (<= im 4.7) (not (<= im 1.9e+129)))
                                                   t_0
                                                   (* (* 0.5 re) (- 1.0 (exp im))))))))
                                          double code(double re, double im) {
                                          	double t_0 = (sin(re) * fma((-0.16666666666666666 * im), im, -1.0)) * im;
                                          	double tmp;
                                          	if (im <= -8.2e+113) {
                                          		tmp = t_0;
                                          	} else if (im <= -6.1) {
                                          		tmp = (re * 0.5) * (exp(-im) - 1.0);
                                          	} else if ((im <= 4.7) || !(im <= 1.9e+129)) {
                                          		tmp = t_0;
                                          	} else {
                                          		tmp = (0.5 * re) * (1.0 - exp(im));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(re, im)
                                          	t_0 = Float64(Float64(sin(re) * fma(Float64(-0.16666666666666666 * im), im, -1.0)) * im)
                                          	tmp = 0.0
                                          	if (im <= -8.2e+113)
                                          		tmp = t_0;
                                          	elseif (im <= -6.1)
                                          		tmp = Float64(Float64(re * 0.5) * Float64(exp(Float64(-im)) - 1.0));
                                          	elseif ((im <= 4.7) || !(im <= 1.9e+129))
                                          		tmp = t_0;
                                          	else
                                          		tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im)));
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[re_, im_] := Block[{t$95$0 = N[(N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * im), $MachinePrecision] * im + -1.0), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[im, -8.2e+113], t$95$0, If[LessEqual[im, -6.1], N[(N[(re * 0.5), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 4.7], N[Not[LessEqual[im, 1.9e+129]], $MachinePrecision]], t$95$0, N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          t_0 := \left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im\\
                                          \mathbf{if}\;im \leq -8.2 \cdot 10^{+113}:\\
                                          \;\;\;\;t\_0\\
                                          
                                          \mathbf{elif}\;im \leq -6.1:\\
                                          \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\
                                          
                                          \mathbf{elif}\;im \leq 4.7 \lor \neg \left(im \leq 1.9 \cdot 10^{+129}\right):\\
                                          \;\;\;\;t\_0\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 3 regimes
                                          2. if im < -8.19999999999999985e113 or -6.0999999999999996 < im < 4.70000000000000018 or 1.90000000000000003e129 < im

                                            1. Initial program 57.8%

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(\sin re \cdot \mathsf{fma}\left(\frac{-1}{6} \cdot im, im, -1\right)\right) \cdot im \]
                                              11. lower-*.f6498.5

                                                \[\leadsto \left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im \]
                                            5. Applied rewrites98.5%

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

                                            if -8.19999999999999985e113 < im < -6.0999999999999996

                                            1. Initial program 100.0%

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

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

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

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

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

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

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

                                              if 4.70000000000000018 < im < 1.90000000000000003e129

                                              1. Initial program 100.0%

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

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

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

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

                                                    \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(1 - e^{im}\right) \]
                                                4. Recombined 3 regimes into one program.
                                                5. Final simplification95.3%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.2 \cdot 10^{+113}:\\ \;\;\;\;\left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im\\ \mathbf{elif}\;im \leq -6.1:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 4.7 \lor \neg \left(im \leq 1.9 \cdot 10^{+129}\right):\\ \;\;\;\;\left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \end{array} \]
                                                6. Add Preprocessing

                                                Alternative 18: 54.7% accurate, 2.2× speedup?

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

                                                  1. Initial program 48.3%

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

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

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

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

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

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

                                                      \[\leadsto \left(-\sin re\right) \cdot im \]
                                                    6. lift-sin.f6457.6

                                                      \[\leadsto \left(-\sin re\right) \cdot im \]
                                                  5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                    10. mul-1-negN/A

                                                      \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                    11. lower-neg.f6413.3

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(re \cdot \left(im \cdot re\right), 0.16666666666666666, -im\right) \cdot re \]
                                                  10. Applied rewrites13.3%

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

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

                                                  1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                                    12. lift-*.f6462.8

                                                      \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                                  8. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                                    13. lift--.f6462.8

                                                      \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                                  11. Applied rewrites62.8%

                                                    \[\leadsto \left(im \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot im\right) \cdot im - 1\right)} \]
                                                  12. Taylor expanded in im around inf

                                                    \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(\frac{-1}{120} \cdot {im}^{2}\right) \cdot im\right) \cdot im - 1\right) \]
                                                  13. Step-by-step derivation
                                                    1. pow2N/A

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

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

                                                      \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{120} \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 1\right) \]
                                                    4. lower-*.f6462.8

                                                      \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 1\right) \]
                                                  14. Applied rewrites62.8%

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

                                                Alternative 19: 52.5% accurate, 2.3× speedup?

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

                                                  1. Initial program 48.3%

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

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

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

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

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

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

                                                      \[\leadsto \left(-\sin re\right) \cdot im \]
                                                    6. lift-sin.f6457.6

                                                      \[\leadsto \left(-\sin re\right) \cdot im \]
                                                  5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                    10. mul-1-negN/A

                                                      \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                    11. lower-neg.f6413.3

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(re \cdot \left(im \cdot re\right), 0.16666666666666666, -im\right) \cdot re \]
                                                  10. Applied rewrites13.3%

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

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

                                                  1. Initial program 75.4%

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

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

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

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

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

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

                                                      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\frac{-1}{3} \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                    6. lower-*.f6480.4

                                                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                  5. Applied rewrites80.4%

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

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

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

                                                  Alternative 20: 49.4% accurate, 2.3× speedup?

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

                                                    1. Initial program 48.3%

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

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

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

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

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

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

                                                        \[\leadsto \left(-\sin re\right) \cdot im \]
                                                      6. lift-sin.f6457.6

                                                        \[\leadsto \left(-\sin re\right) \cdot im \]
                                                    5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                      10. mul-1-negN/A

                                                        \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                      11. lower-neg.f6413.3

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

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

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

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

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

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

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

                                                        \[\leadsto \mathsf{fma}\left(re \cdot \left(im \cdot re\right), 0.16666666666666666, -im\right) \cdot re \]
                                                    10. Applied rewrites13.3%

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

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

                                                    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                                      12. lift-*.f6462.8

                                                        \[\leadsto \left(\left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
                                                    8. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{120} - \frac{1}{6}\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                                      13. lift--.f6462.8

                                                        \[\leadsto \left(im \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.008333333333333333 - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \]
                                                    11. Applied rewrites62.8%

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

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

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

                                                    Alternative 21: 34.1% accurate, 2.3× speedup?

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

                                                      1. Initial program 48.3%

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

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

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

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

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

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

                                                          \[\leadsto \left(-\sin re\right) \cdot im \]
                                                        6. lift-sin.f6457.6

                                                          \[\leadsto \left(-\sin re\right) \cdot im \]
                                                      5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                          \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                        10. mul-1-negN/A

                                                          \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                        11. lower-neg.f6413.3

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

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

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

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

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

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

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

                                                          \[\leadsto \mathsf{fma}\left(re \cdot \left(im \cdot re\right), 0.16666666666666666, -im\right) \cdot re \]
                                                      10. Applied rewrites13.3%

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

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

                                                      1. Initial program 75.4%

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

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

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

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

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

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

                                                          \[\leadsto \left(-\sin re\right) \cdot im \]
                                                        6. lift-sin.f6447.7

                                                          \[\leadsto \left(-\sin re\right) \cdot im \]
                                                      5. Applied rewrites47.7%

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

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

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

                                                      Alternative 22: 34.1% accurate, 2.3× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\ \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot 0.16666666666666666 - 1\right) \cdot im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                                                      (FPCore (re im)
                                                       :precision binary64
                                                       (if (<= (* 0.5 (sin re)) -0.005)
                                                         (* (* (- (* (* re re) 0.16666666666666666) 1.0) im) re)
                                                         (* (- re) im)))
                                                      double code(double re, double im) {
                                                      	double tmp;
                                                      	if ((0.5 * sin(re)) <= -0.005) {
                                                      		tmp = ((((re * re) * 0.16666666666666666) - 1.0) * im) * re;
                                                      	} else {
                                                      		tmp = -re * im;
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      module fmin_fmax_functions
                                                          implicit none
                                                          private
                                                          public fmax
                                                          public fmin
                                                      
                                                          interface fmax
                                                              module procedure fmax88
                                                              module procedure fmax44
                                                              module procedure fmax84
                                                              module procedure fmax48
                                                          end interface
                                                          interface fmin
                                                              module procedure fmin88
                                                              module procedure fmin44
                                                              module procedure fmin84
                                                              module procedure fmin48
                                                          end interface
                                                      contains
                                                          real(8) function fmax88(x, y) result (res)
                                                              real(8), intent (in) :: x
                                                              real(8), intent (in) :: y
                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                          end function
                                                          real(4) function fmax44(x, y) result (res)
                                                              real(4), intent (in) :: x
                                                              real(4), intent (in) :: y
                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                          end function
                                                          real(8) function fmax84(x, y) result(res)
                                                              real(8), intent (in) :: x
                                                              real(4), intent (in) :: y
                                                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                          end function
                                                          real(8) function fmax48(x, y) result(res)
                                                              real(4), intent (in) :: x
                                                              real(8), intent (in) :: y
                                                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                          end function
                                                          real(8) function fmin88(x, y) result (res)
                                                              real(8), intent (in) :: x
                                                              real(8), intent (in) :: y
                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                          end function
                                                          real(4) function fmin44(x, y) result (res)
                                                              real(4), intent (in) :: x
                                                              real(4), intent (in) :: y
                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                          end function
                                                          real(8) function fmin84(x, y) result(res)
                                                              real(8), intent (in) :: x
                                                              real(4), intent (in) :: y
                                                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                          end function
                                                          real(8) function fmin48(x, y) result(res)
                                                              real(4), intent (in) :: x
                                                              real(8), intent (in) :: y
                                                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                          end function
                                                      end module
                                                      
                                                      real(8) function code(re, im)
                                                      use fmin_fmax_functions
                                                          real(8), intent (in) :: re
                                                          real(8), intent (in) :: im
                                                          real(8) :: tmp
                                                          if ((0.5d0 * sin(re)) <= (-0.005d0)) then
                                                              tmp = ((((re * re) * 0.16666666666666666d0) - 1.0d0) * im) * re
                                                          else
                                                              tmp = -re * im
                                                          end if
                                                          code = tmp
                                                      end function
                                                      
                                                      public static double code(double re, double im) {
                                                      	double tmp;
                                                      	if ((0.5 * Math.sin(re)) <= -0.005) {
                                                      		tmp = ((((re * re) * 0.16666666666666666) - 1.0) * im) * re;
                                                      	} else {
                                                      		tmp = -re * im;
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      def code(re, im):
                                                      	tmp = 0
                                                      	if (0.5 * math.sin(re)) <= -0.005:
                                                      		tmp = ((((re * re) * 0.16666666666666666) - 1.0) * im) * re
                                                      	else:
                                                      		tmp = -re * im
                                                      	return tmp
                                                      
                                                      function code(re, im)
                                                      	tmp = 0.0
                                                      	if (Float64(0.5 * sin(re)) <= -0.005)
                                                      		tmp = Float64(Float64(Float64(Float64(Float64(re * re) * 0.16666666666666666) - 1.0) * im) * re);
                                                      	else
                                                      		tmp = Float64(Float64(-re) * im);
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      function tmp_2 = code(re, im)
                                                      	tmp = 0.0;
                                                      	if ((0.5 * sin(re)) <= -0.005)
                                                      		tmp = ((((re * re) * 0.16666666666666666) - 1.0) * im) * re;
                                                      	else
                                                      		tmp = -re * im;
                                                      	end
                                                      	tmp_2 = tmp;
                                                      end
                                                      
                                                      code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(N[(re * re), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - 1.0), $MachinePrecision] * im), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
                                                      \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot 0.16666666666666666 - 1\right) \cdot im\right) \cdot re\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\left(-re\right) \cdot im\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001

                                                        1. Initial program 48.3%

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

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

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

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

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

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

                                                            \[\leadsto \left(-\sin re\right) \cdot im \]
                                                          6. lift-sin.f6457.6

                                                            \[\leadsto \left(-\sin re\right) \cdot im \]
                                                        5. Applied rewrites57.6%

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

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                          10. mul-1-negN/A

                                                            \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                          11. lower-neg.f6413.3

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \left(\left(\left(re \cdot re\right) \cdot 0.16666666666666666 - 1\right) \cdot im\right) \cdot re \]
                                                        11. Applied rewrites13.3%

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

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

                                                        1. Initial program 75.4%

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

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

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

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

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

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

                                                            \[\leadsto \left(-\sin re\right) \cdot im \]
                                                          6. lift-sin.f6447.7

                                                            \[\leadsto \left(-\sin re\right) \cdot im \]
                                                        5. Applied rewrites47.7%

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

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

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

                                                        Alternative 23: 86.2% accurate, 2.4× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -6.1:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\ \mathbf{elif}\;im \leq 3.15:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
                                                        (FPCore (re im)
                                                         :precision binary64
                                                         (if (<= im -6.1)
                                                           (* (* re 0.5) (- (exp (- im)) 1.0))
                                                           (if (<= im 3.15)
                                                             (* (- (sin re)) im)
                                                             (if (<= im 2e+135)
                                                               (* (* 0.5 re) (- 1.0 (exp im)))
                                                               (*
                                                                (* (fma (* re re) -0.08333333333333333 0.5) re)
                                                                (*
                                                                 (-
                                                                  (*
                                                                   (-
                                                                    (* (* (* (* -0.0003968253968253968 im) im) im) im)
                                                                    0.3333333333333333)
                                                                   (* im im))
                                                                  2.0)
                                                                 im))))))
                                                        double code(double re, double im) {
                                                        	double tmp;
                                                        	if (im <= -6.1) {
                                                        		tmp = (re * 0.5) * (exp(-im) - 1.0);
                                                        	} else if (im <= 3.15) {
                                                        		tmp = -sin(re) * im;
                                                        	} else if (im <= 2e+135) {
                                                        		tmp = (0.5 * re) * (1.0 - exp(im));
                                                        	} else {
                                                        		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(re, im)
                                                        	tmp = 0.0
                                                        	if (im <= -6.1)
                                                        		tmp = Float64(Float64(re * 0.5) * Float64(exp(Float64(-im)) - 1.0));
                                                        	elseif (im <= 3.15)
                                                        		tmp = Float64(Float64(-sin(re)) * im);
                                                        	elseif (im <= 2e+135)
                                                        		tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im)));
                                                        	else
                                                        		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        code[re_, im_] := If[LessEqual[im, -6.1], N[(N[(re * 0.5), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.15], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 2e+135], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;im \leq -6.1:\\
                                                        \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(e^{-im} - 1\right)\\
                                                        
                                                        \mathbf{elif}\;im \leq 3.15:\\
                                                        \;\;\;\;\left(-\sin re\right) \cdot im\\
                                                        
                                                        \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\
                                                        \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 4 regimes
                                                        2. if im < -6.0999999999999996

                                                          1. Initial program 100.0%

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

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

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

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

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

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

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

                                                            if -6.0999999999999996 < im < 3.14999999999999991

                                                            1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

                                                            if 3.14999999999999991 < im < 1.99999999999999992e135

                                                            1. Initial program 100.0%

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

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

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

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

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

                                                                if 1.99999999999999992e135 < im

                                                                1. Initial program 100.0%

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

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

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

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

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

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

                                                                    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                  2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                  3. Step-by-step derivation
                                                                    1. *-commutativeN/A

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

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

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

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

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

                                                                      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                    7. lift-*.f6484.8

                                                                      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                  4. Applied rewrites84.8%

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

                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot {im}^{2}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                  6. Step-by-step derivation
                                                                    1. pow2N/A

                                                                      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                    2. associate-*r*N/A

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

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

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

                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                8. Recombined 4 regimes into one program.
                                                                9. Add Preprocessing

                                                                Alternative 24: 84.2% accurate, 2.4× speedup?

                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1360:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{elif}\;im \leq 3.15:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
                                                                (FPCore (re im)
                                                                 :precision binary64
                                                                 (if (<= im -1360.0)
                                                                   (*
                                                                    (* 0.5 re)
                                                                    (*
                                                                     (-
                                                                      (*
                                                                       (-
                                                                        (*
                                                                         (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
                                                                         im)
                                                                        0.3333333333333333)
                                                                       (* im im))
                                                                      2.0)
                                                                     im))
                                                                   (if (<= im 3.15)
                                                                     (* (- (sin re)) im)
                                                                     (if (<= im 2e+135)
                                                                       (* (* 0.5 re) (- 1.0 (exp im)))
                                                                       (*
                                                                        (* (fma (* re re) -0.08333333333333333 0.5) re)
                                                                        (*
                                                                         (-
                                                                          (*
                                                                           (-
                                                                            (* (* (* (* -0.0003968253968253968 im) im) im) im)
                                                                            0.3333333333333333)
                                                                           (* im im))
                                                                          2.0)
                                                                         im))))))
                                                                double code(double re, double im) {
                                                                	double tmp;
                                                                	if (im <= -1360.0) {
                                                                		tmp = (0.5 * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
                                                                	} else if (im <= 3.15) {
                                                                		tmp = -sin(re) * im;
                                                                	} else if (im <= 2e+135) {
                                                                		tmp = (0.5 * re) * (1.0 - exp(im));
                                                                	} else {
                                                                		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                function code(re, im)
                                                                	tmp = 0.0
                                                                	if (im <= -1360.0)
                                                                		tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
                                                                	elseif (im <= 3.15)
                                                                		tmp = Float64(Float64(-sin(re)) * im);
                                                                	elseif (im <= 2e+135)
                                                                		tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im)));
                                                                	else
                                                                		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                code[re_, im_] := If[LessEqual[im, -1360.0], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.15], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 2e+135], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
                                                                
                                                                \begin{array}{l}
                                                                
                                                                \\
                                                                \begin{array}{l}
                                                                \mathbf{if}\;im \leq -1360:\\
                                                                \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
                                                                
                                                                \mathbf{elif}\;im \leq 3.15:\\
                                                                \;\;\;\;\left(-\sin re\right) \cdot im\\
                                                                
                                                                \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\
                                                                \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 4 regimes
                                                                2. if im < -1360

                                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

                                                                    if -1360 < im < 3.14999999999999991

                                                                    1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

                                                                    if 3.14999999999999991 < im < 1.99999999999999992e135

                                                                    1. Initial program 100.0%

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

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

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

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

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

                                                                        if 1.99999999999999992e135 < im

                                                                        1. Initial program 100.0%

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

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

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

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

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

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

                                                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                          2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                          3. Step-by-step derivation
                                                                            1. *-commutativeN/A

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

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

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

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

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

                                                                              \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                            7. lift-*.f6484.8

                                                                              \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                          4. Applied rewrites84.8%

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

                                                                            \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot {im}^{2}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                          6. Step-by-step derivation
                                                                            1. pow2N/A

                                                                              \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                            2. associate-*r*N/A

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

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

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

                                                                            \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                        8. Recombined 4 regimes into one program.
                                                                        9. Add Preprocessing

                                                                        Alternative 25: 34.1% accurate, 2.4× speedup?

                                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\ \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                                                                        (FPCore (re im)
                                                                         :precision binary64
                                                                         (if (<= (* 0.5 (sin re)) -0.005)
                                                                           (* (* (* (* re re) im) 0.16666666666666666) re)
                                                                           (* (- re) im)))
                                                                        double code(double re, double im) {
                                                                        	double tmp;
                                                                        	if ((0.5 * sin(re)) <= -0.005) {
                                                                        		tmp = (((re * re) * im) * 0.16666666666666666) * re;
                                                                        	} else {
                                                                        		tmp = -re * im;
                                                                        	}
                                                                        	return tmp;
                                                                        }
                                                                        
                                                                        module fmin_fmax_functions
                                                                            implicit none
                                                                            private
                                                                            public fmax
                                                                            public fmin
                                                                        
                                                                            interface fmax
                                                                                module procedure fmax88
                                                                                module procedure fmax44
                                                                                module procedure fmax84
                                                                                module procedure fmax48
                                                                            end interface
                                                                            interface fmin
                                                                                module procedure fmin88
                                                                                module procedure fmin44
                                                                                module procedure fmin84
                                                                                module procedure fmin48
                                                                            end interface
                                                                        contains
                                                                            real(8) function fmax88(x, y) result (res)
                                                                                real(8), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(4) function fmax44(x, y) result (res)
                                                                                real(4), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmax84(x, y) result(res)
                                                                                real(8), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmax48(x, y) result(res)
                                                                                real(4), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin88(x, y) result (res)
                                                                                real(8), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(4) function fmin44(x, y) result (res)
                                                                                real(4), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin84(x, y) result(res)
                                                                                real(8), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin48(x, y) result(res)
                                                                                real(4), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                            end function
                                                                        end module
                                                                        
                                                                        real(8) function code(re, im)
                                                                        use fmin_fmax_functions
                                                                            real(8), intent (in) :: re
                                                                            real(8), intent (in) :: im
                                                                            real(8) :: tmp
                                                                            if ((0.5d0 * sin(re)) <= (-0.005d0)) then
                                                                                tmp = (((re * re) * im) * 0.16666666666666666d0) * re
                                                                            else
                                                                                tmp = -re * im
                                                                            end if
                                                                            code = tmp
                                                                        end function
                                                                        
                                                                        public static double code(double re, double im) {
                                                                        	double tmp;
                                                                        	if ((0.5 * Math.sin(re)) <= -0.005) {
                                                                        		tmp = (((re * re) * im) * 0.16666666666666666) * re;
                                                                        	} else {
                                                                        		tmp = -re * im;
                                                                        	}
                                                                        	return tmp;
                                                                        }
                                                                        
                                                                        def code(re, im):
                                                                        	tmp = 0
                                                                        	if (0.5 * math.sin(re)) <= -0.005:
                                                                        		tmp = (((re * re) * im) * 0.16666666666666666) * re
                                                                        	else:
                                                                        		tmp = -re * im
                                                                        	return tmp
                                                                        
                                                                        function code(re, im)
                                                                        	tmp = 0.0
                                                                        	if (Float64(0.5 * sin(re)) <= -0.005)
                                                                        		tmp = Float64(Float64(Float64(Float64(re * re) * im) * 0.16666666666666666) * re);
                                                                        	else
                                                                        		tmp = Float64(Float64(-re) * im);
                                                                        	end
                                                                        	return tmp
                                                                        end
                                                                        
                                                                        function tmp_2 = code(re, im)
                                                                        	tmp = 0.0;
                                                                        	if ((0.5 * sin(re)) <= -0.005)
                                                                        		tmp = (((re * re) * im) * 0.16666666666666666) * re;
                                                                        	else
                                                                        		tmp = -re * im;
                                                                        	end
                                                                        	tmp_2 = tmp;
                                                                        end
                                                                        
                                                                        code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                                                                        
                                                                        \begin{array}{l}
                                                                        
                                                                        \\
                                                                        \begin{array}{l}
                                                                        \mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
                                                                        \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re\\
                                                                        
                                                                        \mathbf{else}:\\
                                                                        \;\;\;\;\left(-re\right) \cdot im\\
                                                                        
                                                                        
                                                                        \end{array}
                                                                        \end{array}
                                                                        
                                                                        Derivation
                                                                        1. Split input into 2 regimes
                                                                        2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001

                                                                          1. Initial program 48.3%

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

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

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

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

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

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

                                                                              \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                            6. lift-sin.f6457.6

                                                                              \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                          5. Applied rewrites57.6%

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

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

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

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

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

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

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

                                                                              \[\leadsto \mathsf{fma}\left({re}^{2} \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                                            7. lower-*.f64N/A

                                                                              \[\leadsto \mathsf{fma}\left({re}^{2} \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                                            8. unpow2N/A

                                                                              \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                                            9. lower-*.f64N/A

                                                                              \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, -1 \cdot im\right) \cdot re \]
                                                                            10. mul-1-negN/A

                                                                              \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, \frac{1}{6}, \mathsf{neg}\left(im\right)\right) \cdot re \]
                                                                            11. lower-neg.f6413.3

                                                                              \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re \]
                                                                          8. Applied rewrites13.3%

                                                                            \[\leadsto \mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot \color{blue}{re} \]
                                                                          9. Taylor expanded in re around inf

                                                                            \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                                                          10. Step-by-step derivation
                                                                            1. *-commutativeN/A

                                                                              \[\leadsto \left(\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}\right) \cdot re \]
                                                                            2. lower-*.f64N/A

                                                                              \[\leadsto \left(\left(im \cdot {re}^{2}\right) \cdot \frac{1}{6}\right) \cdot re \]
                                                                            3. *-commutativeN/A

                                                                              \[\leadsto \left(\left({re}^{2} \cdot im\right) \cdot \frac{1}{6}\right) \cdot re \]
                                                                            4. pow2N/A

                                                                              \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot \frac{1}{6}\right) \cdot re \]
                                                                            5. lift-*.f64N/A

                                                                              \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot \frac{1}{6}\right) \cdot re \]
                                                                            6. lift-*.f6413.3

                                                                              \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re \]
                                                                          11. Applied rewrites13.3%

                                                                            \[\leadsto \left(\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.16666666666666666\right) \cdot re \]

                                                                          if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re))

                                                                          1. Initial program 75.4%

                                                                            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                          2. Add Preprocessing
                                                                          3. Taylor expanded in im around 0

                                                                            \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                                                          4. Step-by-step derivation
                                                                            1. *-commutativeN/A

                                                                              \[\leadsto -1 \cdot \left(\sin re \cdot \color{blue}{im}\right) \]
                                                                            2. associate-*r*N/A

                                                                              \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                            3. lower-*.f64N/A

                                                                              \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                            4. mul-1-negN/A

                                                                              \[\leadsto \left(\mathsf{neg}\left(\sin re\right)\right) \cdot im \]
                                                                            5. lower-neg.f64N/A

                                                                              \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                            6. lift-sin.f6447.7

                                                                              \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                          5. Applied rewrites47.7%

                                                                            \[\leadsto \color{blue}{\left(-\sin re\right) \cdot im} \]
                                                                          6. Taylor expanded in re around 0

                                                                            \[\leadsto \left(-re\right) \cdot im \]
                                                                          7. Step-by-step derivation
                                                                            1. Applied rewrites37.2%

                                                                              \[\leadsto \left(-re\right) \cdot im \]
                                                                          8. Recombined 2 regimes into one program.
                                                                          9. Add Preprocessing

                                                                          Alternative 26: 82.4% accurate, 2.6× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{if}\;im \leq -1360:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 85:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
                                                                          (FPCore (re im)
                                                                           :precision binary64
                                                                           (let* ((t_0
                                                                                   (*
                                                                                    (* 0.5 re)
                                                                                    (*
                                                                                     (-
                                                                                      (*
                                                                                       (-
                                                                                        (*
                                                                                         (*
                                                                                          (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
                                                                                          im)
                                                                                         im)
                                                                                        0.3333333333333333)
                                                                                       (* im im))
                                                                                      2.0)
                                                                                     im))))
                                                                             (if (<= im -1360.0)
                                                                               t_0
                                                                               (if (<= im 85.0)
                                                                                 (* (- (sin re)) im)
                                                                                 (if (<= im 2e+135)
                                                                                   t_0
                                                                                   (*
                                                                                    (* (fma (* re re) -0.08333333333333333 0.5) re)
                                                                                    (*
                                                                                     (-
                                                                                      (*
                                                                                       (-
                                                                                        (* (* (* (* -0.0003968253968253968 im) im) im) im)
                                                                                        0.3333333333333333)
                                                                                       (* im im))
                                                                                      2.0)
                                                                                     im)))))))
                                                                          double code(double re, double im) {
                                                                          	double t_0 = (0.5 * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
                                                                          	double tmp;
                                                                          	if (im <= -1360.0) {
                                                                          		tmp = t_0;
                                                                          	} else if (im <= 85.0) {
                                                                          		tmp = -sin(re) * im;
                                                                          	} else if (im <= 2e+135) {
                                                                          		tmp = t_0;
                                                                          	} else {
                                                                          		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          function code(re, im)
                                                                          	t_0 = Float64(Float64(0.5 * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im))
                                                                          	tmp = 0.0
                                                                          	if (im <= -1360.0)
                                                                          		tmp = t_0;
                                                                          	elseif (im <= 85.0)
                                                                          		tmp = Float64(Float64(-sin(re)) * im);
                                                                          	elseif (im <= 2e+135)
                                                                          		tmp = t_0;
                                                                          	else
                                                                          		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
                                                                          	end
                                                                          	return tmp
                                                                          end
                                                                          
                                                                          code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1360.0], t$95$0, If[LessEqual[im, 85.0], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 2e+135], t$95$0, N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          t_0 := \left(0.5 \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
                                                                          \mathbf{if}\;im \leq -1360:\\
                                                                          \;\;\;\;t\_0\\
                                                                          
                                                                          \mathbf{elif}\;im \leq 85:\\
                                                                          \;\;\;\;\left(-\sin re\right) \cdot im\\
                                                                          
                                                                          \mathbf{elif}\;im \leq 2 \cdot 10^{+135}:\\
                                                                          \;\;\;\;t\_0\\
                                                                          
                                                                          \mathbf{else}:\\
                                                                          \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
                                                                          
                                                                          
                                                                          \end{array}
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Split input into 3 regimes
                                                                          2. if im < -1360 or 85 < im < 1.99999999999999992e135

                                                                            1. Initial program 100.0%

                                                                              \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                            2. Add Preprocessing
                                                                            3. Taylor expanded in im around 0

                                                                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
                                                                            4. Step-by-step derivation
                                                                              1. *-commutativeN/A

                                                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot \color{blue}{im}\right) \]
                                                                              2. lower-*.f64N/A

                                                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot \color{blue}{im}\right) \]
                                                                            5. Applied rewrites74.8%

                                                                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
                                                                            6. Taylor expanded in re around 0

                                                                              \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right) - \frac{1}{60}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                            7. Step-by-step derivation
                                                                              1. Applied rewrites62.9%

                                                                                \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]

                                                                              if -1360 < im < 85

                                                                              1. Initial program 32.5%

                                                                                \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in im around 0

                                                                                \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                                                              4. Step-by-step derivation
                                                                                1. *-commutativeN/A

                                                                                  \[\leadsto -1 \cdot \left(\sin re \cdot \color{blue}{im}\right) \]
                                                                                2. associate-*r*N/A

                                                                                  \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                                3. lower-*.f64N/A

                                                                                  \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                                4. mul-1-negN/A

                                                                                  \[\leadsto \left(\mathsf{neg}\left(\sin re\right)\right) \cdot im \]
                                                                                5. lower-neg.f64N/A

                                                                                  \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                                6. lift-sin.f6499.3

                                                                                  \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                              5. Applied rewrites99.3%

                                                                                \[\leadsto \color{blue}{\left(-\sin re\right) \cdot im} \]

                                                                              if 1.99999999999999992e135 < im

                                                                              1. Initial program 100.0%

                                                                                \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in im around 0

                                                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
                                                                              4. Step-by-step derivation
                                                                                1. *-commutativeN/A

                                                                                  \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot \color{blue}{im}\right) \]
                                                                                2. lower-*.f64N/A

                                                                                  \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot \color{blue}{im}\right) \]
                                                                              5. Applied rewrites100.0%

                                                                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
                                                                              6. Taylor expanded in im around 0

                                                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                              7. Step-by-step derivation
                                                                                1. Applied rewrites100.0%

                                                                                  \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                2. 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 \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                3. Step-by-step derivation
                                                                                  1. *-commutativeN/A

                                                                                    \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  2. lower-*.f64N/A

                                                                                    \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot \color{blue}{re}\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  3. +-commutativeN/A

                                                                                    \[\leadsto \left(\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  4. *-commutativeN/A

                                                                                    \[\leadsto \left(\left({re}^{2} \cdot \frac{-1}{12} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  5. lower-fma.f64N/A

                                                                                    \[\leadsto \left(\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  6. pow2N/A

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  7. lift-*.f6484.8

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                4. Applied rewrites84.8%

                                                                                  \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                5. Taylor expanded in im around inf

                                                                                  \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot {im}^{2}\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                6. Step-by-step derivation
                                                                                  1. pow2N/A

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\frac{-1}{2520} \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  2. associate-*r*N/A

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(\frac{-1}{2520} \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  3. lower-*.f64N/A

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(\frac{-1}{2520} \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - \frac{1}{3}\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                  4. lower-*.f6484.8

                                                                                    \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                                7. Applied rewrites84.8%

                                                                                  \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right) \]
                                                                              8. Recombined 3 regimes into one program.
                                                                              9. Add Preprocessing

                                                                              Alternative 27: 31.9% accurate, 39.5× speedup?

                                                                              \[\begin{array}{l} \\ \left(-re\right) \cdot im \end{array} \]
                                                                              (FPCore (re im) :precision binary64 (* (- re) im))
                                                                              double code(double re, double im) {
                                                                              	return -re * im;
                                                                              }
                                                                              
                                                                              module fmin_fmax_functions
                                                                                  implicit none
                                                                                  private
                                                                                  public fmax
                                                                                  public fmin
                                                                              
                                                                                  interface fmax
                                                                                      module procedure fmax88
                                                                                      module procedure fmax44
                                                                                      module procedure fmax84
                                                                                      module procedure fmax48
                                                                                  end interface
                                                                                  interface fmin
                                                                                      module procedure fmin88
                                                                                      module procedure fmin44
                                                                                      module procedure fmin84
                                                                                      module procedure fmin48
                                                                                  end interface
                                                                              contains
                                                                                  real(8) function fmax88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmax44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmin44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                              end module
                                                                              
                                                                              real(8) function code(re, im)
                                                                              use fmin_fmax_functions
                                                                                  real(8), intent (in) :: re
                                                                                  real(8), intent (in) :: im
                                                                                  code = -re * im
                                                                              end function
                                                                              
                                                                              public static double code(double re, double im) {
                                                                              	return -re * im;
                                                                              }
                                                                              
                                                                              def code(re, im):
                                                                              	return -re * im
                                                                              
                                                                              function code(re, im)
                                                                              	return Float64(Float64(-re) * im)
                                                                              end
                                                                              
                                                                              function tmp = code(re, im)
                                                                              	tmp = -re * im;
                                                                              end
                                                                              
                                                                              code[re_, im_] := N[((-re) * im), $MachinePrecision]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              \left(-re\right) \cdot im
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Initial program 67.1%

                                                                                \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in im around 0

                                                                                \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                                                              4. Step-by-step derivation
                                                                                1. *-commutativeN/A

                                                                                  \[\leadsto -1 \cdot \left(\sin re \cdot \color{blue}{im}\right) \]
                                                                                2. associate-*r*N/A

                                                                                  \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                                3. lower-*.f64N/A

                                                                                  \[\leadsto \left(-1 \cdot \sin re\right) \cdot \color{blue}{im} \]
                                                                                4. mul-1-negN/A

                                                                                  \[\leadsto \left(\mathsf{neg}\left(\sin re\right)\right) \cdot im \]
                                                                                5. lower-neg.f64N/A

                                                                                  \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                                6. lift-sin.f6450.8

                                                                                  \[\leadsto \left(-\sin re\right) \cdot im \]
                                                                              5. Applied rewrites50.8%

                                                                                \[\leadsto \color{blue}{\left(-\sin re\right) \cdot im} \]
                                                                              6. Taylor expanded in re around 0

                                                                                \[\leadsto \left(-re\right) \cdot im \]
                                                                              7. Step-by-step derivation
                                                                                1. Applied rewrites30.9%

                                                                                  \[\leadsto \left(-re\right) \cdot im \]
                                                                                2. Add Preprocessing

                                                                                Developer Target 1: 99.8% accurate, 1.0× speedup?

                                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
                                                                                (FPCore (re im)
                                                                                 :precision binary64
                                                                                 (if (< (fabs im) 1.0)
                                                                                   (-
                                                                                    (*
                                                                                     (sin re)
                                                                                     (+
                                                                                      (+ im (* (* (* 0.16666666666666666 im) im) im))
                                                                                      (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
                                                                                   (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
                                                                                double code(double re, double im) {
                                                                                	double tmp;
                                                                                	if (fabs(im) < 1.0) {
                                                                                		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                	} else {
                                                                                		tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
                                                                                	}
                                                                                	return tmp;
                                                                                }
                                                                                
                                                                                module fmin_fmax_functions
                                                                                    implicit none
                                                                                    private
                                                                                    public fmax
                                                                                    public fmin
                                                                                
                                                                                    interface fmax
                                                                                        module procedure fmax88
                                                                                        module procedure fmax44
                                                                                        module procedure fmax84
                                                                                        module procedure fmax48
                                                                                    end interface
                                                                                    interface fmin
                                                                                        module procedure fmin88
                                                                                        module procedure fmin44
                                                                                        module procedure fmin84
                                                                                        module procedure fmin48
                                                                                    end interface
                                                                                contains
                                                                                    real(8) function fmax88(x, y) result (res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(4) function fmax44(x, y) result (res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmax84(x, y) result(res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmax48(x, y) result(res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin88(x, y) result (res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(4) function fmin44(x, y) result (res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin84(x, y) result(res)
                                                                                        real(8), intent (in) :: x
                                                                                        real(4), intent (in) :: y
                                                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                    end function
                                                                                    real(8) function fmin48(x, y) result(res)
                                                                                        real(4), intent (in) :: x
                                                                                        real(8), intent (in) :: y
                                                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                    end function
                                                                                end module
                                                                                
                                                                                real(8) function code(re, im)
                                                                                use fmin_fmax_functions
                                                                                    real(8), intent (in) :: re
                                                                                    real(8), intent (in) :: im
                                                                                    real(8) :: tmp
                                                                                    if (abs(im) < 1.0d0) then
                                                                                        tmp = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
                                                                                    else
                                                                                        tmp = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
                                                                                    end if
                                                                                    code = tmp
                                                                                end function
                                                                                
                                                                                public static double code(double re, double im) {
                                                                                	double tmp;
                                                                                	if (Math.abs(im) < 1.0) {
                                                                                		tmp = -(Math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                	} else {
                                                                                		tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
                                                                                	}
                                                                                	return tmp;
                                                                                }
                                                                                
                                                                                def code(re, im):
                                                                                	tmp = 0
                                                                                	if math.fabs(im) < 1.0:
                                                                                		tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
                                                                                	else:
                                                                                		tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
                                                                                	return tmp
                                                                                
                                                                                function code(re, im)
                                                                                	tmp = 0.0
                                                                                	if (abs(im) < 1.0)
                                                                                		tmp = Float64(-Float64(sin(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
                                                                                	else
                                                                                		tmp = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)));
                                                                                	end
                                                                                	return tmp
                                                                                end
                                                                                
                                                                                function tmp_2 = code(re, im)
                                                                                	tmp = 0.0;
                                                                                	if (abs(im) < 1.0)
                                                                                		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
                                                                                	else
                                                                                		tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
                                                                                	end
                                                                                	tmp_2 = tmp;
                                                                                end
                                                                                
                                                                                code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                                
                                                                                \begin{array}{l}
                                                                                
                                                                                \\
                                                                                \begin{array}{l}
                                                                                \mathbf{if}\;\left|im\right| < 1:\\
                                                                                \;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
                                                                                
                                                                                \mathbf{else}:\\
                                                                                \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
                                                                                
                                                                                
                                                                                \end{array}
                                                                                \end{array}
                                                                                

                                                                                Reproduce

                                                                                ?
                                                                                herbie shell --seed 2025056 
                                                                                (FPCore (re im)
                                                                                  :name "math.cos on complex, imaginary part"
                                                                                  :precision binary64
                                                                                
                                                                                  :alt
                                                                                  (! :herbie-platform default (if (< (fabs im) 1) (- (* (sin re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (sin re)) (- (exp (- im)) (exp im)))))
                                                                                
                                                                                  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))