math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 38.1s
Alternatives: 8
Speedup: 1.5×

Specification

?
\[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (sin re)) (+ (exp (- 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[(1/2 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)

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?

\[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  (* (* 1/2 (sin re)) (+ (exp (- 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[(1/2 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)

Alternative 1: 100.0% accurate, 1.5× speedup?

\[\sin re \cdot \cosh im \]
(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]
\sin re \cdot \cosh im
Derivation
  1. Initial program 100.0%

    \[\left(\frac{1}{2} \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. cosh-0-revN/A

      \[\leadsto \sin re \cdot \left(\color{blue}{\cosh 0} \cdot \cosh im\right) \]
    15. cosh-0-revN/A

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

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

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
    18. 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: 81.7% accurate, 2.9× speedup?

\[\begin{array}{l} t_0 := \left|im\right| \cdot \left|im\right|\\ \mathbf{if}\;\left|im\right| \leq 6100000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;\left|im\right| \leq 399999999999999993113045090218343426990990578856063590215900480871244616433664:\\ \;\;\;\;\left(re \cdot \left(re \cdot \left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{6}{re \cdot re}\right)\right)\right)\right) \cdot 2\\ \mathbf{elif}\;\left|im\right| \leq 6000000000000000248432939182427692818100624028184179935367669204583630813967171088177433668396288574871737718478838813024662997120339390456701055401984:\\ \;\;\;\;\left(\frac{1}{2} \cdot re\right) \cdot \frac{t\_0 \cdot t\_0 - 2 \cdot 2}{t\_0 - 2}\\ \mathbf{else}:\\ \;\;\;\;\left(t\_0 - -2\right) \cdot \left(re \cdot \frac{1}{2}\right)\\ \end{array} \]
(FPCore (re im)
  :precision binary64
  (let* ((t_0 (* (fabs im) (fabs im))))
  (if (<= (fabs im) 6100000)
    (sin re)
    (if (<=
         (fabs im)
         399999999999999993113045090218343426990990578856063590215900480871244616433664)
      (* (* re (* re (* (* -1/12 re) (- 1 (/ 6 (* re re)))))) 2)
      (if (<=
           (fabs im)
           6000000000000000248432939182427692818100624028184179935367669204583630813967171088177433668396288574871737718478838813024662997120339390456701055401984)
        (* (* 1/2 re) (/ (- (* t_0 t_0) (* 2 2)) (- t_0 2)))
        (* (- t_0 -2) (* re 1/2)))))))
double code(double re, double im) {
	double t_0 = fabs(im) * fabs(im);
	double tmp;
	if (fabs(im) <= 6100000.0) {
		tmp = sin(re);
	} else if (fabs(im) <= 4e+77) {
		tmp = (re * (re * ((-0.08333333333333333 * re) * (1.0 - (6.0 / (re * re)))))) * 2.0;
	} else if (fabs(im) <= 6e+150) {
		tmp = (0.5 * re) * (((t_0 * t_0) - (2.0 * 2.0)) / (t_0 - 2.0));
	} else {
		tmp = (t_0 - -2.0) * (re * 0.5);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = abs(im) * abs(im)
    if (abs(im) <= 6100000.0d0) then
        tmp = sin(re)
    else if (abs(im) <= 4d+77) then
        tmp = (re * (re * (((-0.08333333333333333d0) * re) * (1.0d0 - (6.0d0 / (re * re)))))) * 2.0d0
    else if (abs(im) <= 6d+150) then
        tmp = (0.5d0 * re) * (((t_0 * t_0) - (2.0d0 * 2.0d0)) / (t_0 - 2.0d0))
    else
        tmp = (t_0 - (-2.0d0)) * (re * 0.5d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.abs(im) * Math.abs(im);
	double tmp;
	if (Math.abs(im) <= 6100000.0) {
		tmp = Math.sin(re);
	} else if (Math.abs(im) <= 4e+77) {
		tmp = (re * (re * ((-0.08333333333333333 * re) * (1.0 - (6.0 / (re * re)))))) * 2.0;
	} else if (Math.abs(im) <= 6e+150) {
		tmp = (0.5 * re) * (((t_0 * t_0) - (2.0 * 2.0)) / (t_0 - 2.0));
	} else {
		tmp = (t_0 - -2.0) * (re * 0.5);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.fabs(im) * math.fabs(im)
	tmp = 0
	if math.fabs(im) <= 6100000.0:
		tmp = math.sin(re)
	elif math.fabs(im) <= 4e+77:
		tmp = (re * (re * ((-0.08333333333333333 * re) * (1.0 - (6.0 / (re * re)))))) * 2.0
	elif math.fabs(im) <= 6e+150:
		tmp = (0.5 * re) * (((t_0 * t_0) - (2.0 * 2.0)) / (t_0 - 2.0))
	else:
		tmp = (t_0 - -2.0) * (re * 0.5)
	return tmp
function code(re, im)
	t_0 = Float64(abs(im) * abs(im))
	tmp = 0.0
	if (abs(im) <= 6100000.0)
		tmp = sin(re);
	elseif (abs(im) <= 4e+77)
		tmp = Float64(Float64(re * Float64(re * Float64(Float64(-0.08333333333333333 * re) * Float64(1.0 - Float64(6.0 / Float64(re * re)))))) * 2.0);
	elseif (abs(im) <= 6e+150)
		tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(t_0 * t_0) - Float64(2.0 * 2.0)) / Float64(t_0 - 2.0)));
	else
		tmp = Float64(Float64(t_0 - -2.0) * Float64(re * 0.5));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = abs(im) * abs(im);
	tmp = 0.0;
	if (abs(im) <= 6100000.0)
		tmp = sin(re);
	elseif (abs(im) <= 4e+77)
		tmp = (re * (re * ((-0.08333333333333333 * re) * (1.0 - (6.0 / (re * re)))))) * 2.0;
	elseif (abs(im) <= 6e+150)
		tmp = (0.5 * re) * (((t_0 * t_0) - (2.0 * 2.0)) / (t_0 - 2.0));
	else
		tmp = (t_0 - -2.0) * (re * 0.5);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[im], $MachinePrecision], 6100000], N[Sin[re], $MachinePrecision], If[LessEqual[N[Abs[im], $MachinePrecision], 399999999999999993113045090218343426990990578856063590215900480871244616433664], N[(N[(re * N[(re * N[(N[(-1/12 * re), $MachinePrecision] * N[(1 - N[(6 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[N[Abs[im], $MachinePrecision], 6000000000000000248432939182427692818100624028184179935367669204583630813967171088177433668396288574871737718478838813024662997120339390456701055401984], N[(N[(1/2 * re), $MachinePrecision] * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(2 * 2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - -2), $MachinePrecision] * N[(re * 1/2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot \left|im\right|\\
\mathbf{if}\;\left|im\right| \leq 6100000:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;\left|im\right| \leq 399999999999999993113045090218343426990990578856063590215900480871244616433664:\\
\;\;\;\;\left(re \cdot \left(re \cdot \left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{6}{re \cdot re}\right)\right)\right)\right) \cdot 2\\

\mathbf{elif}\;\left|im\right| \leq 6000000000000000248432939182427692818100624028184179935367669204583630813967171088177433668396288574871737718478838813024662997120339390456701055401984:\\
\;\;\;\;\left(\frac{1}{2} \cdot re\right) \cdot \frac{t\_0 \cdot t\_0 - 2 \cdot 2}{t\_0 - 2}\\

\mathbf{else}:\\
\;\;\;\;\left(t\_0 - -2\right) \cdot \left(re \cdot \frac{1}{2}\right)\\


\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 6.1e6

    1. Initial program 100.0%

      \[\left(\frac{1}{2} \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 rewrites50.3%

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

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
      3. Step-by-step derivation
        1. lower-*.f6426.7%

          \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
      4. Applied rewrites26.7%

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

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

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

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

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
      8. Taylor expanded in im around 0

        \[\leadsto \color{blue}{\sin re} \]
      9. Step-by-step derivation
        1. lower-sin.f6450.3%

          \[\leadsto \sin re \]
      10. Applied rewrites50.3%

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

      if 6.1e6 < im < 3.9999999999999999e77

      1. Initial program 100.0%

        \[\left(\frac{1}{2} \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 rewrites50.3%

          \[\leadsto \left(\frac{1}{2} \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.7%

            \[\leadsto \left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
        4. Applied rewrites34.7%

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

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

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

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

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

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

            \[\leadsto \left(re \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot re\right) \cdot re\right)\right) \cdot 2 \]
        6. Applied rewrites34.7%

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

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

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

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

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

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

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

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

            \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
          9. metadata-evalN/A

            \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)\right)\right) \cdot 2 \]
          10. sub-flipN/A

            \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} - \color{blue}{\frac{-1}{2}}\right)\right) \cdot 2 \]
          11. sub-to-mult-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(re \cdot \left(re \cdot \left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{\frac{-1}{2}}{\frac{-1}{12} \cdot \color{blue}{\left(re \cdot re\right)}}\right)\right)\right)\right) \cdot 2 \]
        8. Applied rewrites35.0%

          \[\leadsto \left(re \cdot \left(re \cdot \color{blue}{\left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{6}{re \cdot re}\right)\right)}\right)\right) \cdot 2 \]

        if 3.9999999999999999e77 < im < 6.0000000000000002e150

        1. Initial program 100.0%

          \[\left(\frac{1}{2} \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 rewrites50.3%

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

            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
          3. Step-by-step derivation
            1. lower-*.f6426.7%

              \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
          4. Applied rewrites26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - 2 \cdot 2}{{im}^{\color{blue}{2}} - 2} \]
            14. lower-unsound--.f6436.0%

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

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

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

              \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - 2 \cdot 2}{im \cdot im - 2} \]
          9. Applied rewrites36.0%

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

          if 6.0000000000000002e150 < im

          1. Initial program 100.0%

            \[\left(\frac{1}{2} \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 rewrites50.3%

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

              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
            3. Step-by-step derivation
              1. lower-*.f6426.7%

                \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
            4. Applied rewrites26.7%

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
              3. lower-*.f6447.5%

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

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

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

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

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

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

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

                \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
              11. metadata-eval47.5%

                \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
              12. metadata-evalN/A

                \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
              13. metadata-evalN/A

                \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
              14. metadata-evalN/A

                \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
            9. Applied rewrites47.5%

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

          Alternative 3: 56.6% accurate, 1.2× speedup?

          \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{5617791046444737}{2808895523222368605827039360607851146278089029597354019897345018089573059460952548948569958162617750330001779372990521213418590137725259726450741103741783193402623334763523207442222181269470220616454421126328215138096104411600982523029892352200425580677351729446660909999175717788745567263052442650378502144}:\\ \;\;\;\;\left(\left|re\right| \cdot \left(\left|re\right| \cdot \left(\left(\frac{-1}{12} \cdot \left|re\right|\right) \cdot \left(1 - \frac{6}{\left|re\right| \cdot \left|re\right|}\right)\right)\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\ \end{array} \]
          (FPCore (re im)
            :precision binary64
            (*
           (copysign 1 re)
           (if (<=
                (* 1/2 (sin (fabs re)))
                5617791046444737/2808895523222368605827039360607851146278089029597354019897345018089573059460952548948569958162617750330001779372990521213418590137725259726450741103741783193402623334763523207442222181269470220616454421126328215138096104411600982523029892352200425580677351729446660909999175717788745567263052442650378502144)
             (*
              (*
               (fabs re)
               (*
                (fabs re)
                (* (* -1/12 (fabs re)) (- 1 (/ 6 (* (fabs re) (fabs re)))))))
              2)
             (* (- (* im im) -2) (* (fabs re) 1/2)))))
          double code(double re, double im) {
          	double tmp;
          	if ((0.5 * sin(fabs(re))) <= 2e-291) {
          		tmp = (fabs(re) * (fabs(re) * ((-0.08333333333333333 * fabs(re)) * (1.0 - (6.0 / (fabs(re) * fabs(re))))))) * 2.0;
          	} else {
          		tmp = ((im * im) - -2.0) * (fabs(re) * 0.5);
          	}
          	return copysign(1.0, re) * tmp;
          }
          
          public static double code(double re, double im) {
          	double tmp;
          	if ((0.5 * Math.sin(Math.abs(re))) <= 2e-291) {
          		tmp = (Math.abs(re) * (Math.abs(re) * ((-0.08333333333333333 * Math.abs(re)) * (1.0 - (6.0 / (Math.abs(re) * Math.abs(re))))))) * 2.0;
          	} else {
          		tmp = ((im * im) - -2.0) * (Math.abs(re) * 0.5);
          	}
          	return Math.copySign(1.0, re) * tmp;
          }
          
          def code(re, im):
          	tmp = 0
          	if (0.5 * math.sin(math.fabs(re))) <= 2e-291:
          		tmp = (math.fabs(re) * (math.fabs(re) * ((-0.08333333333333333 * math.fabs(re)) * (1.0 - (6.0 / (math.fabs(re) * math.fabs(re))))))) * 2.0
          	else:
          		tmp = ((im * im) - -2.0) * (math.fabs(re) * 0.5)
          	return math.copysign(1.0, re) * tmp
          
          function code(re, im)
          	tmp = 0.0
          	if (Float64(0.5 * sin(abs(re))) <= 2e-291)
          		tmp = Float64(Float64(abs(re) * Float64(abs(re) * Float64(Float64(-0.08333333333333333 * abs(re)) * Float64(1.0 - Float64(6.0 / Float64(abs(re) * abs(re))))))) * 2.0);
          	else
          		tmp = Float64(Float64(Float64(im * im) - -2.0) * Float64(abs(re) * 0.5));
          	end
          	return Float64(copysign(1.0, re) * tmp)
          end
          
          function tmp_2 = code(re, im)
          	tmp = 0.0;
          	if ((0.5 * sin(abs(re))) <= 2e-291)
          		tmp = (abs(re) * (abs(re) * ((-0.08333333333333333 * abs(re)) * (1.0 - (6.0 / (abs(re) * abs(re))))))) * 2.0;
          	else
          		tmp = ((im * im) - -2.0) * (abs(re) * 0.5);
          	end
          	tmp_2 = (sign(re) * abs(1.0)) * tmp;
          end
          
          code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5617791046444737/2808895523222368605827039360607851146278089029597354019897345018089573059460952548948569958162617750330001779372990521213418590137725259726450741103741783193402623334763523207442222181269470220616454421126328215138096104411600982523029892352200425580677351729446660909999175717788745567263052442650378502144], N[(N[(N[Abs[re], $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(N[(-1/12 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1 - N[(6 / N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] - -2), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
          
          \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
          \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{5617791046444737}{2808895523222368605827039360607851146278089029597354019897345018089573059460952548948569958162617750330001779372990521213418590137725259726450741103741783193402623334763523207442222181269470220616454421126328215138096104411600982523029892352200425580677351729446660909999175717788745567263052442650378502144}:\\
          \;\;\;\;\left(\left|re\right| \cdot \left(\left|re\right| \cdot \left(\left(\frac{-1}{12} \cdot \left|re\right|\right) \cdot \left(1 - \frac{6}{\left|re\right| \cdot \left|re\right|}\right)\right)\right)\right) \cdot 2\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 1.9999999999999999e-291

            1. Initial program 100.0%

              \[\left(\frac{1}{2} \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 rewrites50.3%

                \[\leadsto \left(\frac{1}{2} \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.7%

                  \[\leadsto \left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
              4. Applied rewrites34.7%

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

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

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

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

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

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

                  \[\leadsto \left(re \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot re\right) \cdot re\right)\right) \cdot 2 \]
              6. Applied rewrites34.7%

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

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

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

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

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

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

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

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

                  \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
                9. metadata-evalN/A

                  \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)\right)\right) \cdot 2 \]
                10. sub-flipN/A

                  \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} - \color{blue}{\frac{-1}{2}}\right)\right) \cdot 2 \]
                11. sub-to-mult-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(re \cdot \left(re \cdot \left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{\frac{-1}{2}}{\frac{-1}{12} \cdot \color{blue}{\left(re \cdot re\right)}}\right)\right)\right)\right) \cdot 2 \]
              8. Applied rewrites35.0%

                \[\leadsto \left(re \cdot \left(re \cdot \color{blue}{\left(\left(\frac{-1}{12} \cdot re\right) \cdot \left(1 - \frac{6}{re \cdot re}\right)\right)}\right)\right) \cdot 2 \]

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

              1. Initial program 100.0%

                \[\left(\frac{1}{2} \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 rewrites50.3%

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

                  \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                3. Step-by-step derivation
                  1. lower-*.f6426.7%

                    \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                4. Applied rewrites26.7%

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
                  3. lower-*.f6447.5%

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

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

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

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

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

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

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

                    \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                  11. metadata-eval47.5%

                    \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                  12. metadata-evalN/A

                    \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
                  13. metadata-evalN/A

                    \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
                  14. metadata-evalN/A

                    \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
                9. Applied rewrites47.5%

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

              Alternative 4: 56.5% accurate, 1.2× speedup?

              \[\begin{array}{l} t_0 := \frac{-1}{12} \cdot \left|re\right|\\ \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{1012011266536553}{101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392}:\\ \;\;\;\;\left(\left|re\right| \cdot \left(\left(\left|re\right| - \frac{\frac{-1}{2}}{t\_0}\right) \cdot t\_0\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\ \end{array} \end{array} \]
              (FPCore (re im)
                :precision binary64
                (let* ((t_0 (* -1/12 (fabs re))))
                (*
                 (copysign 1 re)
                 (if (<=
                      (* 1/2 (sin (fabs re)))
                      1012011266536553/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392)
                   (* (* (fabs re) (* (- (fabs re) (/ -1/2 t_0)) t_0)) 2)
                   (* (- (* im im) -2) (* (fabs re) 1/2))))))
              double code(double re, double im) {
              	double t_0 = -0.08333333333333333 * fabs(re);
              	double tmp;
              	if ((0.5 * sin(fabs(re))) <= 1e-308) {
              		tmp = (fabs(re) * ((fabs(re) - (-0.5 / t_0)) * t_0)) * 2.0;
              	} else {
              		tmp = ((im * im) - -2.0) * (fabs(re) * 0.5);
              	}
              	return copysign(1.0, re) * tmp;
              }
              
              public static double code(double re, double im) {
              	double t_0 = -0.08333333333333333 * Math.abs(re);
              	double tmp;
              	if ((0.5 * Math.sin(Math.abs(re))) <= 1e-308) {
              		tmp = (Math.abs(re) * ((Math.abs(re) - (-0.5 / t_0)) * t_0)) * 2.0;
              	} else {
              		tmp = ((im * im) - -2.0) * (Math.abs(re) * 0.5);
              	}
              	return Math.copySign(1.0, re) * tmp;
              }
              
              def code(re, im):
              	t_0 = -0.08333333333333333 * math.fabs(re)
              	tmp = 0
              	if (0.5 * math.sin(math.fabs(re))) <= 1e-308:
              		tmp = (math.fabs(re) * ((math.fabs(re) - (-0.5 / t_0)) * t_0)) * 2.0
              	else:
              		tmp = ((im * im) - -2.0) * (math.fabs(re) * 0.5)
              	return math.copysign(1.0, re) * tmp
              
              function code(re, im)
              	t_0 = Float64(-0.08333333333333333 * abs(re))
              	tmp = 0.0
              	if (Float64(0.5 * sin(abs(re))) <= 1e-308)
              		tmp = Float64(Float64(abs(re) * Float64(Float64(abs(re) - Float64(-0.5 / t_0)) * t_0)) * 2.0);
              	else
              		tmp = Float64(Float64(Float64(im * im) - -2.0) * Float64(abs(re) * 0.5));
              	end
              	return Float64(copysign(1.0, re) * tmp)
              end
              
              function tmp_2 = code(re, im)
              	t_0 = -0.08333333333333333 * abs(re);
              	tmp = 0.0;
              	if ((0.5 * sin(abs(re))) <= 1e-308)
              		tmp = (abs(re) * ((abs(re) - (-0.5 / t_0)) * t_0)) * 2.0;
              	else
              		tmp = ((im * im) - -2.0) * (abs(re) * 0.5);
              	end
              	tmp_2 = (sign(re) * abs(1.0)) * tmp;
              end
              
              code[re_, im_] := Block[{t$95$0 = N[(-1/12 * N[Abs[re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1012011266536553/101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392], N[(N[(N[Abs[re], $MachinePrecision] * N[(N[(N[Abs[re], $MachinePrecision] - N[(-1/2 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] - -2), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
              
              \begin{array}{l}
              t_0 := \frac{-1}{12} \cdot \left|re\right|\\
              \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
              \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{1012011266536553}{101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392}:\\
              \;\;\;\;\left(\left|re\right| \cdot \left(\left(\left|re\right| - \frac{\frac{-1}{2}}{t\_0}\right) \cdot t\_0\right)\right) \cdot 2\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 9.9999999999999991e-309

                1. Initial program 100.0%

                  \[\left(\frac{1}{2} \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 rewrites50.3%

                    \[\leadsto \left(\frac{1}{2} \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.7%

                      \[\leadsto \left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
                  4. Applied rewrites34.7%

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

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

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

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

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

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

                      \[\leadsto \left(re \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot re\right) \cdot re\right)\right) \cdot 2 \]
                  6. Applied rewrites34.7%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
                    9. metadata-evalN/A

                      \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} + \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)\right)\right) \cdot 2 \]
                    10. sub-flipN/A

                      \[\leadsto \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12} - \color{blue}{\frac{-1}{2}}\right)\right) \cdot 2 \]
                    11. sub-to-mult-revN/A

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(re \cdot \left(\left(re \cdot \left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right)\right) \cdot \color{blue}{\left(\frac{-1}{12} \cdot re\right)}\right)\right) \cdot 2 \]
                  8. Applied rewrites34.6%

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

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

                  1. Initial program 100.0%

                    \[\left(\frac{1}{2} \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 rewrites50.3%

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

                      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                    3. Step-by-step derivation
                      1. lower-*.f6426.7%

                        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                    4. Applied rewrites26.7%

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
                      3. lower-*.f6447.5%

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

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

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

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

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

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

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

                        \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                      11. metadata-eval47.5%

                        \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                      12. metadata-evalN/A

                        \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
                      13. metadata-evalN/A

                        \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
                      14. metadata-evalN/A

                        \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
                    9. Applied rewrites47.5%

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

                  Alternative 5: 56.4% accurate, 1.3× speedup?

                  \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{-5764607523034235}{576460752303423488}:\\ \;\;\;\;\left(\left|re\right| \cdot \left(1 \cdot \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \frac{-1}{12}\right)\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\ \end{array} \]
                  (FPCore (re im)
                    :precision binary64
                    (*
                   (copysign 1 re)
                   (if (<= (* 1/2 (sin (fabs re))) -5764607523034235/576460752303423488)
                     (* (* (fabs re) (* 1 (* (* (fabs re) (fabs re)) -1/12))) 2)
                     (* (- (* im im) -2) (* (fabs re) 1/2)))))
                  double code(double re, double im) {
                  	double tmp;
                  	if ((0.5 * sin(fabs(re))) <= -0.01) {
                  		tmp = (fabs(re) * (1.0 * ((fabs(re) * fabs(re)) * -0.08333333333333333))) * 2.0;
                  	} else {
                  		tmp = ((im * im) - -2.0) * (fabs(re) * 0.5);
                  	}
                  	return copysign(1.0, re) * tmp;
                  }
                  
                  public static double code(double re, double im) {
                  	double tmp;
                  	if ((0.5 * Math.sin(Math.abs(re))) <= -0.01) {
                  		tmp = (Math.abs(re) * (1.0 * ((Math.abs(re) * Math.abs(re)) * -0.08333333333333333))) * 2.0;
                  	} else {
                  		tmp = ((im * im) - -2.0) * (Math.abs(re) * 0.5);
                  	}
                  	return Math.copySign(1.0, re) * tmp;
                  }
                  
                  def code(re, im):
                  	tmp = 0
                  	if (0.5 * math.sin(math.fabs(re))) <= -0.01:
                  		tmp = (math.fabs(re) * (1.0 * ((math.fabs(re) * math.fabs(re)) * -0.08333333333333333))) * 2.0
                  	else:
                  		tmp = ((im * im) - -2.0) * (math.fabs(re) * 0.5)
                  	return math.copysign(1.0, re) * tmp
                  
                  function code(re, im)
                  	tmp = 0.0
                  	if (Float64(0.5 * sin(abs(re))) <= -0.01)
                  		tmp = Float64(Float64(abs(re) * Float64(1.0 * Float64(Float64(abs(re) * abs(re)) * -0.08333333333333333))) * 2.0);
                  	else
                  		tmp = Float64(Float64(Float64(im * im) - -2.0) * Float64(abs(re) * 0.5));
                  	end
                  	return Float64(copysign(1.0, re) * tmp)
                  end
                  
                  function tmp_2 = code(re, im)
                  	tmp = 0.0;
                  	if ((0.5 * sin(abs(re))) <= -0.01)
                  		tmp = (abs(re) * (1.0 * ((abs(re) * abs(re)) * -0.08333333333333333))) * 2.0;
                  	else
                  		tmp = ((im * im) - -2.0) * (abs(re) * 0.5);
                  	end
                  	tmp_2 = (sign(re) * abs(1.0)) * tmp;
                  end
                  
                  code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -5764607523034235/576460752303423488], N[(N[(N[Abs[re], $MachinePrecision] * N[(1 * N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * -1/12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] - -2), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                  
                  \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
                  \mathbf{if}\;\frac{1}{2} \cdot \sin \left(\left|re\right|\right) \leq \frac{-5764607523034235}{576460752303423488}:\\
                  \;\;\;\;\left(\left|re\right| \cdot \left(1 \cdot \left(\left(\left|re\right| \cdot \left|re\right|\right) \cdot \frac{-1}{12}\right)\right)\right) \cdot 2\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.01

                    1. Initial program 100.0%

                      \[\left(\frac{1}{2} \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 rewrites50.3%

                        \[\leadsto \left(\frac{1}{2} \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.7%

                          \[\leadsto \left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
                      4. Applied rewrites34.7%

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

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

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

                          \[\leadsto \left(re \cdot \left(\frac{-1}{12} \cdot {re}^{2} - \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right) \cdot 2 \]
                        4. sub-to-multN/A

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

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

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

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\mathsf{neg}\left(\frac{1}{2}\right)}{\frac{-1}{12} \cdot {re}^{2}}\right) \cdot \left(\frac{-1}{12} \cdot {re}^{2}\right)\right)\right) \cdot 2 \]
                        8. metadata-eval22.7%

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

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

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{{re}^{2} \cdot \frac{-1}{12}}\right) \cdot \left(\frac{-1}{12} \cdot {re}^{2}\right)\right)\right) \cdot 2 \]
                        11. lower-*.f6422.7%

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

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

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right) \cdot \left(\frac{-1}{12} \cdot {re}^{2}\right)\right)\right) \cdot 2 \]
                        14. lower-*.f6422.7%

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

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

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right) \cdot \left({re}^{2} \cdot \color{blue}{\frac{-1}{12}}\right)\right)\right) \cdot 2 \]
                        17. lower-*.f6422.7%

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

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

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right) \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12}\right)\right)\right) \cdot 2 \]
                        20. lower-*.f6422.7%

                          \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right) \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{12}\right)\right)\right) \cdot 2 \]
                      6. Applied rewrites22.7%

                        \[\leadsto \left(re \cdot \left(\left(1 - \frac{\frac{-1}{2}}{\left(re \cdot re\right) \cdot \frac{-1}{12}}\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{12}\right)}\right)\right) \cdot 2 \]
                      7. Taylor expanded in re around inf

                        \[\leadsto \left(re \cdot \left(1 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{12}\right)\right)\right) \cdot 2 \]
                      8. Step-by-step derivation
                        1. Applied rewrites10.9%

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

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

                        1. Initial program 100.0%

                          \[\left(\frac{1}{2} \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 rewrites50.3%

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

                            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                          3. Step-by-step derivation
                            1. lower-*.f6426.7%

                              \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                          4. Applied rewrites26.7%

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

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

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

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

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

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

                              \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
                            3. lower-*.f6447.5%

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

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

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

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

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

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

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

                              \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                            11. metadata-eval47.5%

                              \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                            12. metadata-evalN/A

                              \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
                            13. metadata-evalN/A

                              \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
                            14. metadata-evalN/A

                              \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
                          9. Applied rewrites47.5%

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

                        Alternative 6: 55.8% accurate, 0.7× speedup?

                        \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;\left(\frac{1}{2} \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{0 - im} + e^{im}\right) \leq \frac{-5764607523034235}{288230376151711744}:\\ \;\;\;\;\left(\left|re\right| \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot \left|re\right|\right) \cdot \left|re\right|\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\ \end{array} \]
                        (FPCore (re im)
                          :precision binary64
                          (*
                         (copysign 1 re)
                         (if (<=
                              (* (* 1/2 (sin (fabs re))) (+ (exp (- 0 im)) (exp im)))
                              -5764607523034235/288230376151711744)
                           (* (* (fabs re) (+ 1/2 (* (* -1/12 (fabs re)) (fabs re)))) 2)
                           (* (- (* im im) -2) (* (fabs re) 1/2)))))
                        double code(double re, double im) {
                        	double tmp;
                        	if (((0.5 * sin(fabs(re))) * (exp((0.0 - im)) + exp(im))) <= -0.02) {
                        		tmp = (fabs(re) * (0.5 + ((-0.08333333333333333 * fabs(re)) * fabs(re)))) * 2.0;
                        	} else {
                        		tmp = ((im * im) - -2.0) * (fabs(re) * 0.5);
                        	}
                        	return copysign(1.0, re) * tmp;
                        }
                        
                        public static double code(double re, double im) {
                        	double tmp;
                        	if (((0.5 * Math.sin(Math.abs(re))) * (Math.exp((0.0 - im)) + Math.exp(im))) <= -0.02) {
                        		tmp = (Math.abs(re) * (0.5 + ((-0.08333333333333333 * Math.abs(re)) * Math.abs(re)))) * 2.0;
                        	} else {
                        		tmp = ((im * im) - -2.0) * (Math.abs(re) * 0.5);
                        	}
                        	return Math.copySign(1.0, re) * tmp;
                        }
                        
                        def code(re, im):
                        	tmp = 0
                        	if ((0.5 * math.sin(math.fabs(re))) * (math.exp((0.0 - im)) + math.exp(im))) <= -0.02:
                        		tmp = (math.fabs(re) * (0.5 + ((-0.08333333333333333 * math.fabs(re)) * math.fabs(re)))) * 2.0
                        	else:
                        		tmp = ((im * im) - -2.0) * (math.fabs(re) * 0.5)
                        	return math.copysign(1.0, re) * tmp
                        
                        function code(re, im)
                        	tmp = 0.0
                        	if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(0.0 - im)) + exp(im))) <= -0.02)
                        		tmp = Float64(Float64(abs(re) * Float64(0.5 + Float64(Float64(-0.08333333333333333 * abs(re)) * abs(re)))) * 2.0);
                        	else
                        		tmp = Float64(Float64(Float64(im * im) - -2.0) * Float64(abs(re) * 0.5));
                        	end
                        	return Float64(copysign(1.0, re) * tmp)
                        end
                        
                        function tmp_2 = code(re, im)
                        	tmp = 0.0;
                        	if (((0.5 * sin(abs(re))) * (exp((0.0 - im)) + exp(im))) <= -0.02)
                        		tmp = (abs(re) * (0.5 + ((-0.08333333333333333 * abs(re)) * abs(re)))) * 2.0;
                        	else
                        		tmp = ((im * im) - -2.0) * (abs(re) * 0.5);
                        	end
                        	tmp_2 = (sign(re) * abs(1.0)) * tmp;
                        end
                        
                        code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(1/2 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5764607523034235/288230376151711744], N[(N[(N[Abs[re], $MachinePrecision] * N[(1/2 + N[(N[(-1/12 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] - -2), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                        
                        \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
                        \mathbf{if}\;\left(\frac{1}{2} \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{0 - im} + e^{im}\right) \leq \frac{-5764607523034235}{288230376151711744}:\\
                        \;\;\;\;\left(\left|re\right| \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot \left|re\right|\right) \cdot \left|re\right|\right)\right) \cdot 2\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(im \cdot im - -2\right) \cdot \left(\left|re\right| \cdot \frac{1}{2}\right)\\
                        
                        
                        \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.02

                          1. Initial program 100.0%

                            \[\left(\frac{1}{2} \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 rewrites50.3%

                              \[\leadsto \left(\frac{1}{2} \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.7%

                                \[\leadsto \left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{\color{blue}{2}}\right)\right) \cdot 2 \]
                            4. Applied rewrites34.7%

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

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

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

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

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

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

                                \[\leadsto \left(re \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot re\right) \cdot re\right)\right) \cdot 2 \]
                            6. Applied rewrites34.7%

                              \[\leadsto \left(re \cdot \left(\frac{1}{2} + \left(\frac{-1}{12} \cdot re\right) \cdot \color{blue}{re}\right)\right) \cdot 2 \]

                            if -0.02 < (*.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(\frac{1}{2} \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 rewrites50.3%

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

                                \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                              3. Step-by-step derivation
                                1. lower-*.f6426.7%

                                  \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                              4. Applied rewrites26.7%

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
                                3. lower-*.f6447.5%

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

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

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

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

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

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

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

                                  \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                                11. metadata-eval47.5%

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                                12. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
                                13. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
                                14. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
                              9. Applied rewrites47.5%

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

                            Alternative 7: 47.5% accurate, 16.7× speedup?

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

                              \[\left(\frac{1}{2} \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 rewrites50.3%

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

                                \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                              3. Step-by-step derivation
                                1. lower-*.f6426.7%

                                  \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                              4. Applied rewrites26.7%

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
                                3. lower-*.f6447.5%

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

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

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

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

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

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

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

                                  \[\leadsto \left(im \cdot im - \left(\mathsf{neg}\left(\color{blue}{2}\right)\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                                11. metadata-eval47.5%

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
                                12. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite=>}\left(lift-*.f64, \left(\frac{1}{2} \cdot re\right)\right) \]
                                13. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(*-commutative, \left(re \cdot \frac{1}{2}\right)\right) \]
                                14. metadata-evalN/A

                                  \[\leadsto \left(im \cdot im - -2\right) \cdot \mathsf{Rewrite<=}\left(lift-*.f64, \left(re \cdot \frac{1}{2}\right)\right) \]
                              9. Applied rewrites47.5%

                                \[\leadsto \color{blue}{\left(im \cdot im - -2\right) \cdot \left(re \cdot \frac{1}{2}\right)} \]
                              10. Add Preprocessing

                              Alternative 8: 26.7% accurate, 28.8× speedup?

                              \[\left(\frac{1}{2} \cdot re\right) \cdot 2 \]
                              (FPCore (re im)
                                :precision binary64
                                (* (* 1/2 re) 2))
                              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[(1/2 * re), $MachinePrecision] * 2), $MachinePrecision]
                              
                              \left(\frac{1}{2} \cdot re\right) \cdot 2
                              
                              Derivation
                              1. Initial program 100.0%

                                \[\left(\frac{1}{2} \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 rewrites50.3%

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

                                  \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot 2 \]
                                3. Step-by-step derivation
                                  1. lower-*.f6426.7%

                                    \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{re}\right) \cdot 2 \]
                                4. Applied rewrites26.7%

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

                                Reproduce

                                ?
                                herbie shell --seed 2025271 -o generate:evaluate
                                (FPCore (re im)
                                  :name "math.sin on complex, real part"
                                  :precision binary64
                                  (* (* 1/2 (sin re)) (+ (exp (- 0 im)) (exp im))))