math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 5.4s
Alternatives: 8
Speedup: 1.4×

Specification

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

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

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 100.0% accurate, 1.4× speedup?

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

\\
\sin re \cdot \cosh im
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    14. *-lft-identityN/A

      \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
    15. lower-*.f64N/A

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
    16. lower-cosh.f64100.0

      \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
  4. Add Preprocessing

Alternative 2: 87.0% accurate, 0.4× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;re \cdot \cosh im\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
      14. *-lft-identityN/A

        \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
      15. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
      16. lower-cosh.f64100.0

        \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
    3. Applied rewrites100.0%

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
    4. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cosh im \cdot \left(\left(\frac{-1}{6} \cdot {re}^{2} + 1\right) \cdot re\right) \]
      10. lower-fma.f6462.9

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right) \]
    4. Applied rewrites75.7%

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left({im}^{2} \cdot \frac{1}{2} + 1\right) \]
      9. lower-fma.f6475.7

        \[\leadsto \sin re \cdot \mathsf{fma}\left({im}^{2}, \color{blue}{0.5}, 1\right) \]
      10. lift-pow.f64N/A

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

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

        \[\leadsto \sin re \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right) \]
    6. Applied rewrites75.7%

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
      14. *-lft-identityN/A

        \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
      15. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
      16. lower-cosh.f64100.0

        \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
    3. Applied rewrites100.0%

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
    4. Taylor expanded in re around 0

      \[\leadsto \color{blue}{re} \cdot \cosh im \]
    5. Step-by-step derivation
      1. Applied rewrites62.4%

        \[\leadsto \color{blue}{re} \cdot \cosh im \]
    6. Recombined 3 regimes into one program.
    7. Add Preprocessing

    Alternative 3: 86.8% accurate, 0.4× speedup?

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
        14. *-lft-identityN/A

          \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
        15. lower-*.f64N/A

          \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
        16. lower-cosh.f64100.0

          \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
      3. Applied rewrites100.0%

        \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
      4. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \cosh im \cdot \left(\left(\frac{-1}{6} \cdot {re}^{2} + 1\right) \cdot re\right) \]
        10. lower-fma.f6462.9

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

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

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

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

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

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
        14. *-lft-identityN/A

          \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
        15. lower-*.f64N/A

          \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
        16. lower-cosh.f64100.0

          \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
      3. Applied rewrites100.0%

        \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
      4. Taylor expanded in im around 0

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

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

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

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
          14. *-lft-identityN/A

            \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
          15. lower-*.f64N/A

            \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
          16. lower-cosh.f64100.0

            \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
        3. Applied rewrites100.0%

          \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
        4. Taylor expanded in re around 0

          \[\leadsto \color{blue}{re} \cdot \cosh im \]
        5. Step-by-step derivation
          1. Applied rewrites62.4%

            \[\leadsto \color{blue}{re} \cdot \cosh im \]
        6. Recombined 3 regimes into one program.
        7. Add Preprocessing

        Alternative 4: 62.5% accurate, 0.7× speedup?

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

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
            14. *-lft-identityN/A

              \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
            15. lower-*.f64N/A

              \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
            16. lower-cosh.f64100.0

              \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
          3. Applied rewrites100.0%

            \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
          4. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \cosh im \cdot \left(\left(\frac{-1}{6} \cdot {re}^{2} + 1\right) \cdot re\right) \]
            10. lower-fma.f6462.9

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

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

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

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

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

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

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
            14. *-lft-identityN/A

              \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
            15. lower-*.f64N/A

              \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
            16. lower-cosh.f64100.0

              \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
          3. Applied rewrites100.0%

            \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
          4. Taylor expanded in re around 0

            \[\leadsto \color{blue}{re} \cdot \cosh im \]
          5. Step-by-step derivation
            1. Applied rewrites62.4%

              \[\leadsto \color{blue}{re} \cdot \cosh im \]
          6. Recombined 2 regimes into one program.
          7. Add Preprocessing

          Alternative 5: 48.7% accurate, 0.7× speedup?

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

            1. Initial program 100.0%

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

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

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

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

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

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

                  \[\leadsto \left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
              4. Applied rewrites34.4%

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

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

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

                  \[\leadsto \color{blue}{2 \cdot \left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{2}\right)\right)} \]
                4. lift-*.f64N/A

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

                  \[\leadsto 2 \cdot \left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot \color{blue}{re}\right) \]
                6. lower-*.f6434.4

                  \[\leadsto 2 \cdot \left(\left(0.5 + -0.08333333333333333 \cdot {re}^{2}\right) \cdot \color{blue}{re}\right) \]
                7. lift-+.f64N/A

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

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

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

                  \[\leadsto 2 \cdot \left(\left({re}^{2} \cdot \frac{-1}{12} + \frac{1}{2}\right) \cdot re\right) \]
                11. lower-fma.f6434.4

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left({re}^{2}, -0.08333333333333333, 0.5\right) \cdot re\right) \]
                12. lift-pow.f64N/A

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

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
                14. lower-*.f6434.4

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \]
              6. Applied rewrites34.4%

                \[\leadsto \color{blue}{2 \cdot \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \]
              7. Step-by-step derivation
                1. rem-square-sqrtN/A

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left(\sqrt{re \cdot re} \cdot \sqrt{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
                2. sqrt-unprodN/A

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

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left(\sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
                4. lower-*.f6435.2

                  \[\leadsto 2 \cdot \left(\mathsf{fma}\left(\sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}, -0.08333333333333333, 0.5\right) \cdot re\right) \]
              8. Applied rewrites35.2%

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

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

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
                14. *-lft-identityN/A

                  \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
                15. lower-*.f64N/A

                  \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
                16. lower-cosh.f64100.0

                  \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
              3. Applied rewrites100.0%

                \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
              4. Taylor expanded in re around 0

                \[\leadsto \color{blue}{re} \cdot \cosh im \]
              5. Step-by-step derivation
                1. Applied rewrites62.4%

                  \[\leadsto \color{blue}{re} \cdot \cosh im \]
              6. Recombined 2 regimes into one program.
              7. Add Preprocessing

              Alternative 6: 48.1% accurate, 0.8× speedup?

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

                1. Initial program 100.0%

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

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

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

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

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

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

                      \[\leadsto \left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
                  4. Applied rewrites34.4%

                    \[\leadsto \color{blue}{\left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{2}\right)\right)} \cdot 2 \]
                  5. Taylor expanded in re around inf

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

                      \[\leadsto \left(\frac{-1}{12} \cdot {re}^{\color{blue}{3}}\right) \cdot 2 \]
                    2. lower-pow.f6411.0

                      \[\leadsto \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
                  7. Applied rewrites11.0%

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

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

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

                      \[\leadsto \left(\frac{-1}{12} \cdot \left(re \cdot \left(re \cdot \color{blue}{re}\right)\right)\right) \cdot 2 \]
                    4. lift-*.f64N/A

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

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

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

                      \[\leadsto \left(\left(re \cdot re\right) \cdot \left(\frac{-1}{12} \cdot \color{blue}{re}\right)\right) \cdot 2 \]
                    8. lower-*.f6411.0

                      \[\leadsto \left(\left(re \cdot re\right) \cdot \left(-0.08333333333333333 \cdot \color{blue}{re}\right)\right) \cdot 2 \]
                  9. Applied rewrites11.0%

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

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

                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
                    14. *-lft-identityN/A

                      \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
                    15. lower-*.f64N/A

                      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
                    16. lower-cosh.f64100.0

                      \[\leadsto \sin re \cdot \color{blue}{\cosh im} \]
                  3. Applied rewrites100.0%

                    \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
                  4. Taylor expanded in re around 0

                    \[\leadsto \color{blue}{re} \cdot \cosh im \]
                  5. Step-by-step derivation
                    1. Applied rewrites62.4%

                      \[\leadsto \color{blue}{re} \cdot \cosh im \]
                  6. Recombined 2 regimes into one program.
                  7. Add Preprocessing

                  Alternative 7: 30.2% accurate, 0.8× speedup?

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

                    1. Initial program 100.0%

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

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

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

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

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

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

                          \[\leadsto \left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
                      4. Applied rewrites34.4%

                        \[\leadsto \color{blue}{\left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{2}\right)\right)} \cdot 2 \]
                      5. Taylor expanded in re around inf

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

                          \[\leadsto \left(\frac{-1}{12} \cdot {re}^{\color{blue}{3}}\right) \cdot 2 \]
                        2. lower-pow.f6411.0

                          \[\leadsto \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
                      7. Applied rewrites11.0%

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

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

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

                          \[\leadsto \left(\frac{-1}{12} \cdot \left(re \cdot \left(re \cdot \color{blue}{re}\right)\right)\right) \cdot 2 \]
                        4. lift-*.f64N/A

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

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

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

                          \[\leadsto \left(\left(re \cdot re\right) \cdot \left(\frac{-1}{12} \cdot \color{blue}{re}\right)\right) \cdot 2 \]
                        8. lower-*.f6411.0

                          \[\leadsto \left(\left(re \cdot re\right) \cdot \left(-0.08333333333333333 \cdot \color{blue}{re}\right)\right) \cdot 2 \]
                      9. Applied rewrites11.0%

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

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

                      1. Initial program 100.0%

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

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

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

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

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

                        Alternative 8: 26.4% accurate, 9.3× speedup?

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

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

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

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

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

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

                            Reproduce

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