math.cos on complex, imaginary part

Percentage Accurate: 65.6% → 99.9%
Time: 5.0s
Alternatives: 9
Speedup: 1.3×

Specification

?
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  :pre TRUE
  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(re, im):
	re in [-inf, +inf],
	im in [-inf, +inf]
code: THEORY
BEGIN
f(re, im: real): real =
	((5e-1) * (sin(re))) * ((exp((- im))) - (exp(im)))
END code
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-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 9 alternatives:

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

Initial Program: 65.6% accurate, 1.0× speedup?

\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
(FPCore (re im)
  :precision binary64
  :pre TRUE
  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(re, im):
	re in [-inf, +inf],
	im in [-inf, +inf]
code: THEORY
BEGIN
f(re, im: real): real =
	((5e-1) * (sin(re))) * ((exp((- im))) - (exp(im)))
END code
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)

Alternative 1: 99.9% accurate, 1.3× speedup?

\[\sinh \left(-im\right) \cdot \sin re \]
(FPCore (re im)
  :precision binary64
  :pre TRUE
  (* (sinh (- im)) (sin re)))
double code(double re, double im) {
	return sinh(-im) * sin(re);
}
real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sinh(-im) * sin(re)
end function
public static double code(double re, double im) {
	return Math.sinh(-im) * Math.sin(re);
}
def code(re, im):
	return math.sinh(-im) * math.sin(re)
function code(re, im)
	return Float64(sinh(Float64(-im)) * sin(re))
end
function tmp = code(re, im)
	tmp = sinh(-im) * sin(re);
end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
f(re, im):
	re in [-inf, +inf],
	im in [-inf, +inf]
code: THEORY
BEGIN
f(re, im: real): real =
	(((1) / (2)) * ((exp((- im))) + ((- (1)) / (exp((- im)))))) * (sin(re))
END code
\sinh \left(-im\right) \cdot \sin re
Derivation
  1. Initial program 65.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. Applied rewrites99.9%

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

    Alternative 2: 98.6% accurate, 0.3× speedup?

    \[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := e^{\left|im\right|}\\ t_2 := \sin \left(\left|re\right|\right)\\ t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\ \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-8}:\\ \;\;\;\;t\_2 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\\ \end{array}\right) \end{array} \]
    (FPCore (re im)
      :precision binary64
      :pre TRUE
      (let* ((t_0 (- (fabs im)))
           (t_1 (exp (fabs im)))
           (t_2 (sin (fabs re)))
           (t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
      (*
       (copysign 1.0 re)
       (*
        (copysign 1.0 im)
        (if (<= t_3 (- INFINITY))
          (* (* 0.5 (fabs re)) (- 1.0 t_1))
          (if (<= t_3 4e-8)
            (* t_2 t_0)
            (*
             (sinh t_0)
             (*
              (fabs re)
              (+ 1.0 (* -0.16666666666666666 (pow (fabs re) 2.0)))))))))))
    double code(double re, double im) {
    	double t_0 = -fabs(im);
    	double t_1 = exp(fabs(im));
    	double t_2 = sin(fabs(re));
    	double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
    	double tmp;
    	if (t_3 <= -((double) INFINITY)) {
    		tmp = (0.5 * fabs(re)) * (1.0 - t_1);
    	} else if (t_3 <= 4e-8) {
    		tmp = t_2 * t_0;
    	} else {
    		tmp = sinh(t_0) * (fabs(re) * (1.0 + (-0.16666666666666666 * pow(fabs(re), 2.0))));
    	}
    	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
    }
    
    public static double code(double re, double im) {
    	double t_0 = -Math.abs(im);
    	double t_1 = Math.exp(Math.abs(im));
    	double t_2 = Math.sin(Math.abs(re));
    	double t_3 = (0.5 * t_2) * (Math.exp(t_0) - t_1);
    	double tmp;
    	if (t_3 <= -Double.POSITIVE_INFINITY) {
    		tmp = (0.5 * Math.abs(re)) * (1.0 - t_1);
    	} else if (t_3 <= 4e-8) {
    		tmp = t_2 * t_0;
    	} else {
    		tmp = Math.sinh(t_0) * (Math.abs(re) * (1.0 + (-0.16666666666666666 * Math.pow(Math.abs(re), 2.0))));
    	}
    	return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
    }
    
    def code(re, im):
    	t_0 = -math.fabs(im)
    	t_1 = math.exp(math.fabs(im))
    	t_2 = math.sin(math.fabs(re))
    	t_3 = (0.5 * t_2) * (math.exp(t_0) - t_1)
    	tmp = 0
    	if t_3 <= -math.inf:
    		tmp = (0.5 * math.fabs(re)) * (1.0 - t_1)
    	elif t_3 <= 4e-8:
    		tmp = t_2 * t_0
    	else:
    		tmp = math.sinh(t_0) * (math.fabs(re) * (1.0 + (-0.16666666666666666 * math.pow(math.fabs(re), 2.0))))
    	return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
    
    function code(re, im)
    	t_0 = Float64(-abs(im))
    	t_1 = exp(abs(im))
    	t_2 = sin(abs(re))
    	t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1))
    	tmp = 0.0
    	if (t_3 <= Float64(-Inf))
    		tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1));
    	elseif (t_3 <= 4e-8)
    		tmp = Float64(t_2 * t_0);
    	else
    		tmp = Float64(sinh(t_0) * Float64(abs(re) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(re) ^ 2.0)))));
    	end
    	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
    end
    
    function tmp_2 = code(re, im)
    	t_0 = -abs(im);
    	t_1 = exp(abs(im));
    	t_2 = sin(abs(re));
    	t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
    	tmp = 0.0;
    	if (t_3 <= -Inf)
    		tmp = (0.5 * abs(re)) * (1.0 - t_1);
    	elseif (t_3 <= 4e-8)
    		tmp = t_2 * t_0;
    	else
    		tmp = sinh(t_0) * (abs(re) * (1.0 + (-0.16666666666666666 * (abs(re) ^ 2.0))));
    	end
    	tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp);
    end
    
    code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4e-8], N[(t$95$2 * t$95$0), $MachinePrecision], N[(N[Sinh[t$95$0], $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
    
    \begin{array}{l}
    t_0 := -\left|im\right|\\
    t_1 := e^{\left|im\right|}\\
    t_2 := \sin \left(\left|re\right|\right)\\
    t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
    \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
    \mathbf{if}\;t\_3 \leq -\infty:\\
    \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
    
    \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-8}:\\
    \;\;\;\;t\_2 \cdot t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\\
    
    
    \end{array}\right)
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0

      1. Initial program 65.6%

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

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

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

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

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

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

          1. Initial program 65.6%

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

            \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
          3. Step-by-step derivation
            1. Applied rewrites51.8%

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

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

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

              1. Initial program 65.6%

                \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
              2. Step-by-step derivation
                1. Applied rewrites99.9%

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

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

                    \[\leadsto \sinh \left(-im\right) \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\right) \]
                4. Recombined 3 regimes into one program.
                5. Add Preprocessing

                Alternative 3: 96.7% accurate, 0.3× speedup?

                \[\begin{array}{l} t_0 := -\left|im\right|\\ t_1 := e^{\left|im\right|}\\ t_2 := \sin \left(\left|re\right|\right)\\ t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\ \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-8}:\\ \;\;\;\;t\_2 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(\left|im\right| \cdot \mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, 0.16666666666666666, -1\right)\right) \cdot \left|re\right|\\ \end{array}\right) \end{array} \]
                (FPCore (re im)
                  :precision binary64
                  :pre TRUE
                  (let* ((t_0 (- (fabs im)))
                       (t_1 (exp (fabs im)))
                       (t_2 (sin (fabs re)))
                       (t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
                  (*
                   (copysign 1.0 re)
                   (*
                    (copysign 1.0 im)
                    (if (<= t_3 (- INFINITY))
                      (* (* 0.5 (fabs re)) (- 1.0 t_1))
                      (if (<= t_3 4e-8)
                        (* t_2 t_0)
                        (*
                         (*
                          (fabs im)
                          (fma (* (fabs re) (fabs re)) 0.16666666666666666 -1.0))
                         (fabs re))))))))
                double code(double re, double im) {
                	double t_0 = -fabs(im);
                	double t_1 = exp(fabs(im));
                	double t_2 = sin(fabs(re));
                	double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
                	double tmp;
                	if (t_3 <= -((double) INFINITY)) {
                		tmp = (0.5 * fabs(re)) * (1.0 - t_1);
                	} else if (t_3 <= 4e-8) {
                		tmp = t_2 * t_0;
                	} else {
                		tmp = (fabs(im) * fma((fabs(re) * fabs(re)), 0.16666666666666666, -1.0)) * fabs(re);
                	}
                	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
                }
                
                function code(re, im)
                	t_0 = Float64(-abs(im))
                	t_1 = exp(abs(im))
                	t_2 = sin(abs(re))
                	t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1))
                	tmp = 0.0
                	if (t_3 <= Float64(-Inf))
                		tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1));
                	elseif (t_3 <= 4e-8)
                		tmp = Float64(t_2 * t_0);
                	else
                		tmp = Float64(Float64(abs(im) * fma(Float64(abs(re) * abs(re)), 0.16666666666666666, -1.0)) * abs(re));
                	end
                	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
                end
                
                code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4e-8], N[(t$95$2 * t$95$0), $MachinePrecision], N[(N[(N[Abs[im], $MachinePrecision] * N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
                
                \begin{array}{l}
                t_0 := -\left|im\right|\\
                t_1 := e^{\left|im\right|}\\
                t_2 := \sin \left(\left|re\right|\right)\\
                t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
                \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
                \mathbf{if}\;t\_3 \leq -\infty:\\
                \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
                
                \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-8}:\\
                \;\;\;\;t\_2 \cdot t\_0\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\left|im\right| \cdot \mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, 0.16666666666666666, -1\right)\right) \cdot \left|re\right|\\
                
                
                \end{array}\right)
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0

                  1. Initial program 65.6%

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

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

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

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

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

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

                      1. Initial program 65.6%

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

                        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites51.8%

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

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

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

                          1. Initial program 65.6%

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

                            \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites51.8%

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

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

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

                                  \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites36.4%

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

                                Alternative 4: 73.2% accurate, 0.9× speedup?

                                \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.01:\\ \;\;\;\;\left|re\right| \cdot \left(\left(\left(im \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot \left(\left|re\right| \cdot 0.5\right)\\ \end{array} \]
                                (FPCore (re im)
                                  :precision binary64
                                  :pre TRUE
                                  (*
                                 (copysign 1.0 re)
                                 (if (<= (* 0.5 (sin (fabs re))) -0.01)
                                   (*
                                    (fabs re)
                                    (- (* (* (* im (fabs re)) (fabs re)) 0.16666666666666666) im))
                                   (* (* -2.0 (sinh im)) (* (fabs re) 0.5)))))
                                double code(double re, double im) {
                                	double tmp;
                                	if ((0.5 * sin(fabs(re))) <= -0.01) {
                                		tmp = fabs(re) * ((((im * fabs(re)) * fabs(re)) * 0.16666666666666666) - im);
                                	} else {
                                		tmp = (-2.0 * sinh(im)) * (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) * ((((im * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - im);
                                	} else {
                                		tmp = (-2.0 * Math.sinh(im)) * (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) * ((((im * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - im)
                                	else:
                                		tmp = (-2.0 * math.sinh(im)) * (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(abs(re) * Float64(Float64(Float64(Float64(im * abs(re)) * abs(re)) * 0.16666666666666666) - im));
                                	else
                                		tmp = Float64(Float64(-2.0 * sinh(im)) * 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) * ((((im * abs(re)) * abs(re)) * 0.16666666666666666) - im);
                                	else
                                		tmp = (-2.0 * sinh(im)) * (abs(re) * 0.5);
                                	end
                                	tmp_2 = (sign(re) * abs(1.0)) * tmp;
                                end
                                
                                code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                
                                \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
                                \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.01:\\
                                \;\;\;\;\left|re\right| \cdot \left(\left(\left(im \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\left(-2 \cdot \sinh im\right) \cdot \left(\left|re\right| \cdot 0.5\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 65.6%

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

                                    \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites51.8%

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

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

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

                                          \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites36.5%

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

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

                                          1. Initial program 65.6%

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

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

                                              \[\leadsto \left(0.5 \cdot re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites62.7%

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

                                            Alternative 5: 73.2% accurate, 0.9× speedup?

                                            \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.01:\\ \;\;\;\;\left|re\right| \cdot \left(\left(\left(im \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sinh \left(-im\right)}{\frac{1}{\left|re\right|}}\\ \end{array} \]
                                            (FPCore (re im)
                                              :precision binary64
                                              :pre TRUE
                                              (*
                                             (copysign 1.0 re)
                                             (if (<= (* 0.5 (sin (fabs re))) -0.01)
                                               (*
                                                (fabs re)
                                                (- (* (* (* im (fabs re)) (fabs re)) 0.16666666666666666) im))
                                               (/ (sinh (- im)) (/ 1.0 (fabs re))))))
                                            double code(double re, double im) {
                                            	double tmp;
                                            	if ((0.5 * sin(fabs(re))) <= -0.01) {
                                            		tmp = fabs(re) * ((((im * fabs(re)) * fabs(re)) * 0.16666666666666666) - im);
                                            	} else {
                                            		tmp = sinh(-im) / (1.0 / fabs(re));
                                            	}
                                            	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) * ((((im * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - im);
                                            	} else {
                                            		tmp = Math.sinh(-im) / (1.0 / Math.abs(re));
                                            	}
                                            	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) * ((((im * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - im)
                                            	else:
                                            		tmp = math.sinh(-im) / (1.0 / math.fabs(re))
                                            	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(abs(re) * Float64(Float64(Float64(Float64(im * abs(re)) * abs(re)) * 0.16666666666666666) - im));
                                            	else
                                            		tmp = Float64(sinh(Float64(-im)) / Float64(1.0 / abs(re)));
                                            	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) * ((((im * abs(re)) * abs(re)) * 0.16666666666666666) - im);
                                            	else
                                            		tmp = sinh(-im) / (1.0 / abs(re));
                                            	end
                                            	tmp_2 = (sign(re) * abs(1.0)) * tmp;
                                            end
                                            
                                            code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[Sinh[(-im)], $MachinePrecision] / N[(1.0 / N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                            
                                            \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
                                            \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.01:\\
                                            \;\;\;\;\left|re\right| \cdot \left(\left(\left(im \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\frac{\sinh \left(-im\right)}{\frac{1}{\left|re\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 65.6%

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

                                                \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites51.8%

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

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

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

                                                      \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites36.5%

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

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

                                                      1. Initial program 65.6%

                                                        \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites99.9%

                                                          \[\leadsto \sinh \left(-im\right) \cdot \sin re \]
                                                        2. Applied rewrites99.4%

                                                          \[\leadsto \frac{1}{\frac{2}{\left(-2 \cdot \sinh im\right) \cdot \sin re}} \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites99.8%

                                                            \[\leadsto \frac{\sinh \left(-im\right)}{\frac{1}{\sin re}} \]
                                                          2. Taylor expanded in re around 0

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

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

                                                          Alternative 6: 72.5% accurate, 0.6× speedup?

                                                          \[\begin{array}{l} t_0 := e^{\left|im\right|}\\ \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{-\left|im\right|} - t\_0\right) \leq -4 \cdot 10^{-12}:\\ \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\left|re\right| \cdot \left(\left(\left(\left|im\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|im\right|\right)\\ \end{array}\right) \end{array} \]
                                                          (FPCore (re im)
                                                            :precision binary64
                                                            :pre TRUE
                                                            (let* ((t_0 (exp (fabs im))))
                                                            (*
                                                             (copysign 1.0 re)
                                                             (*
                                                              (copysign 1.0 im)
                                                              (if (<=
                                                                   (* (* 0.5 (sin (fabs re))) (- (exp (- (fabs im))) t_0))
                                                                   -4e-12)
                                                                (* (* 0.5 (fabs re)) (- 1.0 t_0))
                                                                (*
                                                                 (fabs re)
                                                                 (-
                                                                  (* (* (* (fabs im) (fabs re)) (fabs re)) 0.16666666666666666)
                                                                  (fabs im))))))))
                                                          double code(double re, double im) {
                                                          	double t_0 = exp(fabs(im));
                                                          	double tmp;
                                                          	if (((0.5 * sin(fabs(re))) * (exp(-fabs(im)) - t_0)) <= -4e-12) {
                                                          		tmp = (0.5 * fabs(re)) * (1.0 - t_0);
                                                          	} else {
                                                          		tmp = fabs(re) * ((((fabs(im) * fabs(re)) * fabs(re)) * 0.16666666666666666) - fabs(im));
                                                          	}
                                                          	return copysign(1.0, re) * (copysign(1.0, im) * tmp);
                                                          }
                                                          
                                                          public static double code(double re, double im) {
                                                          	double t_0 = Math.exp(Math.abs(im));
                                                          	double tmp;
                                                          	if (((0.5 * Math.sin(Math.abs(re))) * (Math.exp(-Math.abs(im)) - t_0)) <= -4e-12) {
                                                          		tmp = (0.5 * Math.abs(re)) * (1.0 - t_0);
                                                          	} else {
                                                          		tmp = Math.abs(re) * ((((Math.abs(im) * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - Math.abs(im));
                                                          	}
                                                          	return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
                                                          }
                                                          
                                                          def code(re, im):
                                                          	t_0 = math.exp(math.fabs(im))
                                                          	tmp = 0
                                                          	if ((0.5 * math.sin(math.fabs(re))) * (math.exp(-math.fabs(im)) - t_0)) <= -4e-12:
                                                          		tmp = (0.5 * math.fabs(re)) * (1.0 - t_0)
                                                          	else:
                                                          		tmp = math.fabs(re) * ((((math.fabs(im) * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - math.fabs(im))
                                                          	return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
                                                          
                                                          function code(re, im)
                                                          	t_0 = exp(abs(im))
                                                          	tmp = 0.0
                                                          	if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(-abs(im))) - t_0)) <= -4e-12)
                                                          		tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_0));
                                                          	else
                                                          		tmp = Float64(abs(re) * Float64(Float64(Float64(Float64(abs(im) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(im)));
                                                          	end
                                                          	return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp))
                                                          end
                                                          
                                                          function tmp_2 = code(re, im)
                                                          	t_0 = exp(abs(im));
                                                          	tmp = 0.0;
                                                          	if (((0.5 * sin(abs(re))) * (exp(-abs(im)) - t_0)) <= -4e-12)
                                                          		tmp = (0.5 * abs(re)) * (1.0 - t_0);
                                                          	else
                                                          		tmp = abs(re) * ((((abs(im) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(im));
                                                          	end
                                                          	tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp);
                                                          end
                                                          
                                                          code[re_, im_] := Block[{t$95$0 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], -4e-12], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          \begin{array}{l}
                                                          t_0 := e^{\left|im\right|}\\
                                                          \mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
                                                          \mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{-\left|im\right|} - t\_0\right) \leq -4 \cdot 10^{-12}:\\
                                                          \;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_0\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\left|re\right| \cdot \left(\left(\left(\left|im\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|im\right|\right)\\
                                                          
                                                          
                                                          \end{array}\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 (neg.f64 im)) (exp.f64 im))) < -3.9999999999999999e-12

                                                            1. Initial program 65.6%

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

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

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

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

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

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

                                                                1. Initial program 65.6%

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

                                                                  \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites51.8%

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

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

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

                                                                        \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                                                      2. Step-by-step derivation
                                                                        1. Applied rewrites36.5%

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

                                                                      Alternative 7: 43.3% accurate, 1.0× speedup?

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

                                                                        1. Initial program 65.6%

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

                                                                          \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites51.8%

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

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

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

                                                                                \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                                                              2. Step-by-step derivation
                                                                                1. Applied rewrites36.5%

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

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

                                                                                1. Initial program 65.6%

                                                                                  \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                                2. Step-by-step derivation
                                                                                  1. Applied rewrites99.9%

                                                                                    \[\leadsto \sinh \left(-im\right) \cdot \sin re \]
                                                                                  2. Applied rewrites99.4%

                                                                                    \[\leadsto \frac{1}{\frac{2}{\left(-2 \cdot \sinh im\right) \cdot \sin re}} \]
                                                                                  3. Taylor expanded in im around 0

                                                                                    \[\leadsto \frac{1}{\frac{-1}{im \cdot \sin re}} \]
                                                                                  4. Step-by-step derivation
                                                                                    1. Applied rewrites51.3%

                                                                                      \[\leadsto \frac{1}{\frac{-1}{im \cdot \sin re}} \]
                                                                                    2. Taylor expanded in re around 0

                                                                                      \[\leadsto \frac{1}{\frac{-1}{im \cdot re}} \]
                                                                                    3. Step-by-step derivation
                                                                                      1. Applied rewrites32.2%

                                                                                        \[\leadsto \frac{1}{\frac{-1}{im \cdot re}} \]
                                                                                    4. Recombined 2 regimes into one program.
                                                                                    5. Add Preprocessing

                                                                                    Alternative 8: 43.3% accurate, 1.0× speedup?

                                                                                    \[\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l} \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 2 \cdot 10^{-7}:\\ \;\;\;\;\left(im \cdot \mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, 0.16666666666666666, -1\right)\right) \cdot \left|re\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-1}{im \cdot \left|re\right|}}\\ \end{array} \]
                                                                                    (FPCore (re im)
                                                                                      :precision binary64
                                                                                      :pre TRUE
                                                                                      (*
                                                                                     (copysign 1.0 re)
                                                                                     (if (<= (* 0.5 (sin (fabs re))) 2e-7)
                                                                                       (*
                                                                                        (* im (fma (* (fabs re) (fabs re)) 0.16666666666666666 -1.0))
                                                                                        (fabs re))
                                                                                       (/ 1.0 (/ -1.0 (* im (fabs re)))))))
                                                                                    double code(double re, double im) {
                                                                                    	double tmp;
                                                                                    	if ((0.5 * sin(fabs(re))) <= 2e-7) {
                                                                                    		tmp = (im * fma((fabs(re) * fabs(re)), 0.16666666666666666, -1.0)) * fabs(re);
                                                                                    	} else {
                                                                                    		tmp = 1.0 / (-1.0 / (im * fabs(re)));
                                                                                    	}
                                                                                    	return copysign(1.0, re) * tmp;
                                                                                    }
                                                                                    
                                                                                    function code(re, im)
                                                                                    	tmp = 0.0
                                                                                    	if (Float64(0.5 * sin(abs(re))) <= 2e-7)
                                                                                    		tmp = Float64(Float64(im * fma(Float64(abs(re) * abs(re)), 0.16666666666666666, -1.0)) * abs(re));
                                                                                    	else
                                                                                    		tmp = Float64(1.0 / Float64(-1.0 / Float64(im * abs(re))));
                                                                                    	end
                                                                                    	return Float64(copysign(1.0, re) * tmp)
                                                                                    end
                                                                                    
                                                                                    code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2e-7], N[(N[(im * N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(-1.0 / N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                                                                    
                                                                                    \mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
                                                                                    \mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq 2 \cdot 10^{-7}:\\
                                                                                    \;\;\;\;\left(im \cdot \mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, 0.16666666666666666, -1\right)\right) \cdot \left|re\right|\\
                                                                                    
                                                                                    \mathbf{else}:\\
                                                                                    \;\;\;\;\frac{1}{\frac{-1}{im \cdot \left|re\right|}}\\
                                                                                    
                                                                                    
                                                                                    \end{array}
                                                                                    
                                                                                    Derivation
                                                                                    1. Split input into 2 regimes
                                                                                    2. if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 1.9999999999999999e-7

                                                                                      1. Initial program 65.6%

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

                                                                                        \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                                                                      3. Step-by-step derivation
                                                                                        1. Applied rewrites51.8%

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

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

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

                                                                                              \[\leadsto re \cdot \mathsf{fma}\left(-1, im, 0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right) \]
                                                                                            2. Step-by-step derivation
                                                                                              1. Applied rewrites36.4%

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

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

                                                                                              1. Initial program 65.6%

                                                                                                \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
                                                                                              2. Step-by-step derivation
                                                                                                1. Applied rewrites99.9%

                                                                                                  \[\leadsto \sinh \left(-im\right) \cdot \sin re \]
                                                                                                2. Applied rewrites99.4%

                                                                                                  \[\leadsto \frac{1}{\frac{2}{\left(-2 \cdot \sinh im\right) \cdot \sin re}} \]
                                                                                                3. Taylor expanded in im around 0

                                                                                                  \[\leadsto \frac{1}{\frac{-1}{im \cdot \sin re}} \]
                                                                                                4. Step-by-step derivation
                                                                                                  1. Applied rewrites51.3%

                                                                                                    \[\leadsto \frac{1}{\frac{-1}{im \cdot \sin re}} \]
                                                                                                  2. Taylor expanded in re around 0

                                                                                                    \[\leadsto \frac{1}{\frac{-1}{im \cdot re}} \]
                                                                                                  3. Step-by-step derivation
                                                                                                    1. Applied rewrites32.2%

                                                                                                      \[\leadsto \frac{1}{\frac{-1}{im \cdot re}} \]
                                                                                                  4. Recombined 2 regimes into one program.
                                                                                                  5. Add Preprocessing

                                                                                                  Alternative 9: 32.6% accurate, 13.2× speedup?

                                                                                                  \[-im \cdot re \]
                                                                                                  (FPCore (re im)
                                                                                                    :precision binary64
                                                                                                    :pre TRUE
                                                                                                    (- (* im re)))
                                                                                                  double code(double re, double im) {
                                                                                                  	return -(im * re);
                                                                                                  }
                                                                                                  
                                                                                                  real(8) function code(re, im)
                                                                                                  use fmin_fmax_functions
                                                                                                      real(8), intent (in) :: re
                                                                                                      real(8), intent (in) :: im
                                                                                                      code = -(im * re)
                                                                                                  end function
                                                                                                  
                                                                                                  public static double code(double re, double im) {
                                                                                                  	return -(im * re);
                                                                                                  }
                                                                                                  
                                                                                                  def code(re, im):
                                                                                                  	return -(im * re)
                                                                                                  
                                                                                                  function code(re, im)
                                                                                                  	return Float64(-Float64(im * re))
                                                                                                  end
                                                                                                  
                                                                                                  function tmp = code(re, im)
                                                                                                  	tmp = -(im * re);
                                                                                                  end
                                                                                                  
                                                                                                  code[re_, im_] := (-N[(im * re), $MachinePrecision])
                                                                                                  
                                                                                                  f(re, im):
                                                                                                  	re in [-inf, +inf],
                                                                                                  	im in [-inf, +inf]
                                                                                                  code: THEORY
                                                                                                  BEGIN
                                                                                                  f(re, im: real): real =
                                                                                                  	- (im * re)
                                                                                                  END code
                                                                                                  -im \cdot re
                                                                                                  
                                                                                                  Derivation
                                                                                                  1. Initial program 65.6%

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

                                                                                                    \[\leadsto -1 \cdot \left(im \cdot \sin re\right) \]
                                                                                                  3. Step-by-step derivation
                                                                                                    1. Applied rewrites51.8%

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

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

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

                                                                                                          \[\leadsto -im \cdot re \]
                                                                                                        2. Add Preprocessing

                                                                                                        Reproduce

                                                                                                        ?
                                                                                                        herbie shell --seed 2025363 
                                                                                                        (FPCore (re im)
                                                                                                          :name "math.cos on complex, imaginary part"
                                                                                                          :precision binary64
                                                                                                          (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))