math.sin on complex, imaginary part

Percentage Accurate: 54.1% → 99.8%
Time: 9.3s
Alternatives: 15
Speedup: 2.9×

Specification

?
\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 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: 54.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.2 \lor \neg \left(t_0 \leq 0.0005\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -0.2) (not (<= t_0 0.0005)))
     (* (* 0.5 (cos re)) t_0)
     (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -0.2) || !(t_0 <= 0.0005)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-0.2d0)) .or. (.not. (t_0 <= 0.0005d0))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -0.2) || !(t_0 <= 0.0005)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -0.2) or not (t_0 <= 0.0005):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -0.2) || !(t_0 <= 0.0005))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -0.2) || ~((t_0 <= 0.0005)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.2], N[Not[LessEqual[t$95$0, 0.0005]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.2 \lor \neg \left(t_0 \leq 0.0005\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.20000000000000001 or 5.0000000000000001e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

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

    if -0.20000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000001e-4

    1. Initial program 9.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg9.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified9.4%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.7%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg99.7%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative99.7%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*99.7%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.7%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified99.7%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -0.2 \lor \neg \left(e^{-im} - e^{im} \leq 0.0005\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 2: 95.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{if}\;im \leq -3.5 \cdot 10^{+128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.265:\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{elif}\;im \leq 0.102 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im)))
        (t_1 (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))))
   (if (<= im -3.5e+128)
     t_1
     (if (<= im -0.265)
       (* 0.5 t_0)
       (if (or (<= im 0.102) (not (<= im 5.6e+102)))
         t_1
         (* t_0 (+ 0.5 (* re (* re -0.25)))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -3.5e+128) {
		tmp = t_1;
	} else if (im <= -0.265) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.102) || !(im <= 5.6e+102)) {
		tmp = t_1;
	} else {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    t_1 = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    if (im <= (-3.5d+128)) then
        tmp = t_1
    else if (im <= (-0.265d0)) then
        tmp = 0.5d0 * t_0
    else if ((im <= 0.102d0) .or. (.not. (im <= 5.6d+102))) then
        tmp = t_1
    else
        tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double t_1 = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -3.5e+128) {
		tmp = t_1;
	} else if (im <= -0.265) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.102) || !(im <= 5.6e+102)) {
		tmp = t_1;
	} else {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	tmp = 0
	if im <= -3.5e+128:
		tmp = t_1
	elif im <= -0.265:
		tmp = 0.5 * t_0
	elif (im <= 0.102) or not (im <= 5.6e+102):
		tmp = t_1
	else:
		tmp = t_0 * (0.5 + (re * (re * -0.25)))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	tmp = 0.0
	if (im <= -3.5e+128)
		tmp = t_1;
	elseif (im <= -0.265)
		tmp = Float64(0.5 * t_0);
	elseif ((im <= 0.102) || !(im <= 5.6e+102))
		tmp = t_1;
	else
		tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	tmp = 0.0;
	if (im <= -3.5e+128)
		tmp = t_1;
	elseif (im <= -0.265)
		tmp = 0.5 * t_0;
	elseif ((im <= 0.102) || ~((im <= 5.6e+102)))
		tmp = t_1;
	else
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.5e+128], t$95$1, If[LessEqual[im, -0.265], N[(0.5 * t$95$0), $MachinePrecision], If[Or[LessEqual[im, 0.102], N[Not[LessEqual[im, 5.6e+102]], $MachinePrecision]], t$95$1, N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -3.5 \cdot 10^{+128}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.265:\\
\;\;\;\;0.5 \cdot t_0\\

\mathbf{elif}\;im \leq 0.102 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.49999999999999969e128 or -0.26500000000000001 < im < 0.101999999999999993 or 5.60000000000000037e102 < im

    1. Initial program 43.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg43.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified43.5%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.8%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg99.8%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative99.8%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]

    if -3.49999999999999969e128 < im < -0.26500000000000001

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 82.1%

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

    if 0.101999999999999993 < im < 5.60000000000000037e102

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg99.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 9.4%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative9.4%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*9.4%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out71.4%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative71.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative71.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow271.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*71.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified71.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.5 \cdot 10^{+128}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -0.265:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.102 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 3: 95.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.5 \cdot 10^{+128} \lor \neg \left(im \leq -0.092 \lor \neg \left(im \leq 0.039\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -3.5e+128)
         (not (or (<= im -0.092) (and (not (<= im 0.039)) (<= im 5.6e+102)))))
   (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
   (* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -3.5e+128) || !((im <= -0.092) || (!(im <= 0.039) && (im <= 5.6e+102)))) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = 0.5 * (exp(-im) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-3.5d+128)) .or. (.not. (im <= (-0.092d0)) .or. (.not. (im <= 0.039d0)) .and. (im <= 5.6d+102))) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else
        tmp = 0.5d0 * (exp(-im) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -3.5e+128) || !((im <= -0.092) || (!(im <= 0.039) && (im <= 5.6e+102)))) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -3.5e+128) or not ((im <= -0.092) or (not (im <= 0.039) and (im <= 5.6e+102))):
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	else:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -3.5e+128) || !((im <= -0.092) || (!(im <= 0.039) && (im <= 5.6e+102))))
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	else
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -3.5e+128) || ~(((im <= -0.092) || (~((im <= 0.039)) && (im <= 5.6e+102)))))
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	else
		tmp = 0.5 * (exp(-im) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -3.5e+128], N[Not[Or[LessEqual[im, -0.092], And[N[Not[LessEqual[im, 0.039]], $MachinePrecision], LessEqual[im, 5.6e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.5 \cdot 10^{+128} \lor \neg \left(im \leq -0.092 \lor \neg \left(im \leq 0.039\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.49999999999999969e128 or -0.091999999999999998 < im < 0.0389999999999999999 or 5.60000000000000037e102 < im

    1. Initial program 43.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg43.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified43.5%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.8%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg99.8%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative99.8%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]

    if -3.49999999999999969e128 < im < -0.091999999999999998 or 0.0389999999999999999 < im < 5.60000000000000037e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 75.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.5 \cdot 10^{+128} \lor \neg \left(im \leq -0.092 \lor \neg \left(im \leq 0.039\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 4: 92.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.00192:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.0018:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
   (if (<= im -6.8e+143)
     t_1
     (if (<= im -0.00192)
       t_0
       (if (<= im 0.0018)
         (* im (- (cos re)))
         (if (<= im 1.3e+152) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_1;
	} else if (im <= -0.00192) {
		tmp = t_0;
	} else if (im <= 0.0018) {
		tmp = im * -cos(re);
	} else if (im <= 1.3e+152) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
    if (im <= (-6.8d+143)) then
        tmp = t_1
    else if (im <= (-0.00192d0)) then
        tmp = t_0
    else if (im <= 0.0018d0) then
        tmp = im * -cos(re)
    else if (im <= 1.3d+152) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_1;
	} else if (im <= -0.00192) {
		tmp = t_0;
	} else if (im <= 0.0018) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.3e+152) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0)
	tmp = 0
	if im <= -6.8e+143:
		tmp = t_1
	elif im <= -0.00192:
		tmp = t_0
	elif im <= 0.0018:
		tmp = im * -math.cos(re)
	elif im <= 1.3e+152:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0))
	tmp = 0.0
	if (im <= -6.8e+143)
		tmp = t_1;
	elseif (im <= -0.00192)
		tmp = t_0;
	elseif (im <= 0.0018)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.3e+152)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	tmp = 0.0;
	if (im <= -6.8e+143)
		tmp = t_1;
	elseif (im <= -0.00192)
		tmp = t_0;
	elseif (im <= 0.0018)
		tmp = im * -cos(re);
	elseif (im <= 1.3e+152)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.8e+143], t$95$1, If[LessEqual[im, -0.00192], t$95$0, If[LessEqual[im, 0.0018], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.3e+152], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.00192:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 0.0018:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.79999999999999964e143 or 1.3e152 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg100.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Applied egg-rr6.9%

      \[\leadsto \cos re \cdot \left(\color{blue}{-3} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

        \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \cos re} \]
      2. flip--95.6%

        \[\leadsto \color{blue}{\frac{-3 \cdot -3 - im \cdot im}{-3 + im}} \cdot \cos re \]
      3. associate-*l/95.6%

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot -3 - im \cdot im\right) \cdot \cos re}{-3 + im}} \]
      4. metadata-eval95.6%

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative95.6%

        \[\leadsto \frac{\left(9 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3}} \]
    9. Applied egg-rr95.6%

      \[\leadsto \color{blue}{\frac{\left(9 - im \cdot im\right) \cdot \cos re}{im + -3}} \]

    if -6.79999999999999964e143 < im < -0.00192000000000000005 or 0.0018 < im < 1.3e152

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 75.8%

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

    if -0.00192000000000000005 < im < 0.0018

    1. Initial program 9.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg9.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified9.4%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.2%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative99.2%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.2%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified99.2%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -0.00192:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.0018:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 5: 81.9% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ t_2 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -5.6 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (- (* im (* 0.5 (* re re))) im))
        (t_2 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
   (if (<= im -6.8e+143)
     t_2
     (if (<= im -5.6e+102)
       t_0
       (if (<= im -5.6e+24)
         (* re (* re 0.75))
         (if (<= im 3.2e+30)
           (* im (- (cos re)))
           (if (<= im 2.8e+64)
             t_1
             (if (<= im 7.5e+144) t_0 (if (<= im 1.35e+154) t_1 t_2)))))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (im * (0.5 * (re * re))) - im;
	double t_2 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_2;
	} else if (im <= -5.6e+102) {
		tmp = t_0;
	} else if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.2e+30) {
		tmp = im * -cos(re);
	} else if (im <= 2.8e+64) {
		tmp = t_1;
	} else if (im <= 7.5e+144) {
		tmp = t_0;
	} else if (im <= 1.35e+154) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_1 = (im * (0.5d0 * (re * re))) - im
    t_2 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
    if (im <= (-6.8d+143)) then
        tmp = t_2
    else if (im <= (-5.6d+102)) then
        tmp = t_0
    else if (im <= (-5.6d+24)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 3.2d+30) then
        tmp = im * -cos(re)
    else if (im <= 2.8d+64) then
        tmp = t_1
    else if (im <= 7.5d+144) then
        tmp = t_0
    else if (im <= 1.35d+154) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (im * (0.5 * (re * re))) - im;
	double t_2 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_2;
	} else if (im <= -5.6e+102) {
		tmp = t_0;
	} else if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.2e+30) {
		tmp = im * -Math.cos(re);
	} else if (im <= 2.8e+64) {
		tmp = t_1;
	} else if (im <= 7.5e+144) {
		tmp = t_0;
	} else if (im <= 1.35e+154) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_1 = (im * (0.5 * (re * re))) - im
	t_2 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0)
	tmp = 0
	if im <= -6.8e+143:
		tmp = t_2
	elif im <= -5.6e+102:
		tmp = t_0
	elif im <= -5.6e+24:
		tmp = re * (re * 0.75)
	elif im <= 3.2e+30:
		tmp = im * -math.cos(re)
	elif im <= 2.8e+64:
		tmp = t_1
	elif im <= 7.5e+144:
		tmp = t_0
	elif im <= 1.35e+154:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im)
	t_2 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0))
	tmp = 0.0
	if (im <= -6.8e+143)
		tmp = t_2;
	elseif (im <= -5.6e+102)
		tmp = t_0;
	elseif (im <= -5.6e+24)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 3.2e+30)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 2.8e+64)
		tmp = t_1;
	elseif (im <= 7.5e+144)
		tmp = t_0;
	elseif (im <= 1.35e+154)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_1 = (im * (0.5 * (re * re))) - im;
	t_2 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	tmp = 0.0;
	if (im <= -6.8e+143)
		tmp = t_2;
	elseif (im <= -5.6e+102)
		tmp = t_0;
	elseif (im <= -5.6e+24)
		tmp = re * (re * 0.75);
	elseif (im <= 3.2e+30)
		tmp = im * -cos(re);
	elseif (im <= 2.8e+64)
		tmp = t_1;
	elseif (im <= 7.5e+144)
		tmp = t_0;
	elseif (im <= 1.35e+154)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.8e+143], t$95$2, If[LessEqual[im, -5.6e+102], t$95$0, If[LessEqual[im, -5.6e+24], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.2e+30], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 2.8e+64], t$95$1, If[LessEqual[im, 7.5e+144], t$95$0, If[LessEqual[im, 1.35e+154], t$95$1, t$95$2]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
t_2 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq -5.6 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -5.6 \cdot 10^{+24}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -6.79999999999999964e143 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg100.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Applied egg-rr7.0%

      \[\leadsto \cos re \cdot \left(\color{blue}{-3} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.0%

        \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \cos re} \]
      2. flip--98.5%

        \[\leadsto \color{blue}{\frac{-3 \cdot -3 - im \cdot im}{-3 + im}} \cdot \cos re \]
      3. associate-*l/98.5%

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot -3 - im \cdot im\right) \cdot \cos re}{-3 + im}} \]
      4. metadata-eval98.5%

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative98.5%

        \[\leadsto \frac{\left(9 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3}} \]
    9. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\left(9 - im \cdot im\right) \cdot \cos re}{im + -3}} \]

    if -6.79999999999999964e143 < im < -5.60000000000000037e102 or 2.80000000000000024e64 < im < 7.5000000000000006e144

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 76.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg76.6%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg76.6%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative76.6%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*76.6%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--76.6%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified76.6%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 68.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -5.60000000000000037e102 < im < -5.6000000000000003e24

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out64.7%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow264.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified64.7%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr29.9%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 30.3%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative30.3%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow230.3%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*30.3%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified30.3%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -5.6000000000000003e24 < im < 3.19999999999999973e30

    1. Initial program 15.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg15.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 92.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg92.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative92.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in92.6%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified92.6%

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

    if 3.19999999999999973e30 < im < 2.80000000000000024e64 or 7.5000000000000006e144 < im < 1.35000000000000003e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 3.8%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg3.8%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative3.8%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.8%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified3.8%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 69.8%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-169.8%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative69.8%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg69.8%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative69.8%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative69.8%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*69.8%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow269.8%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified69.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -5.6 \cdot 10^{+102}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 6: 82.7% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ t_2 := \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot t_0\\ \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -3.05 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -3 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0)))
        (t_2 (* (* -0.5 (* re re)) t_0)))
   (if (<= im -6.8e+143)
     t_1
     (if (<= im -3.05e+92)
       t_0
       (if (<= im -3e+20)
         t_2
         (if (<= im 5e+30)
           (* im (- (cos re)))
           (if (<= im 1.8e+96)
             t_2
             (if (<= im 7.5e+144)
               t_0
               (if (<= im 1.35e+154)
                 (- (* im (* 0.5 (* re re))) im)
                 t_1)))))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double t_2 = (-0.5 * (re * re)) * t_0;
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_1;
	} else if (im <= -3.05e+92) {
		tmp = t_0;
	} else if (im <= -3e+20) {
		tmp = t_2;
	} else if (im <= 5e+30) {
		tmp = im * -cos(re);
	} else if (im <= 1.8e+96) {
		tmp = t_2;
	} else if (im <= 7.5e+144) {
		tmp = t_0;
	} else if (im <= 1.35e+154) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
    t_2 = ((-0.5d0) * (re * re)) * t_0
    if (im <= (-6.8d+143)) then
        tmp = t_1
    else if (im <= (-3.05d+92)) then
        tmp = t_0
    else if (im <= (-3d+20)) then
        tmp = t_2
    else if (im <= 5d+30) then
        tmp = im * -cos(re)
    else if (im <= 1.8d+96) then
        tmp = t_2
    else if (im <= 7.5d+144) then
        tmp = t_0
    else if (im <= 1.35d+154) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double t_2 = (-0.5 * (re * re)) * t_0;
	double tmp;
	if (im <= -6.8e+143) {
		tmp = t_1;
	} else if (im <= -3.05e+92) {
		tmp = t_0;
	} else if (im <= -3e+20) {
		tmp = t_2;
	} else if (im <= 5e+30) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.8e+96) {
		tmp = t_2;
	} else if (im <= 7.5e+144) {
		tmp = t_0;
	} else if (im <= 1.35e+154) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0)
	t_2 = (-0.5 * (re * re)) * t_0
	tmp = 0
	if im <= -6.8e+143:
		tmp = t_1
	elif im <= -3.05e+92:
		tmp = t_0
	elif im <= -3e+20:
		tmp = t_2
	elif im <= 5e+30:
		tmp = im * -math.cos(re)
	elif im <= 1.8e+96:
		tmp = t_2
	elif im <= 7.5e+144:
		tmp = t_0
	elif im <= 1.35e+154:
		tmp = (im * (0.5 * (re * re))) - im
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0))
	t_2 = Float64(Float64(-0.5 * Float64(re * re)) * t_0)
	tmp = 0.0
	if (im <= -6.8e+143)
		tmp = t_1;
	elseif (im <= -3.05e+92)
		tmp = t_0;
	elseif (im <= -3e+20)
		tmp = t_2;
	elseif (im <= 5e+30)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.8e+96)
		tmp = t_2;
	elseif (im <= 7.5e+144)
		tmp = t_0;
	elseif (im <= 1.35e+154)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	t_2 = (-0.5 * (re * re)) * t_0;
	tmp = 0.0;
	if (im <= -6.8e+143)
		tmp = t_1;
	elseif (im <= -3.05e+92)
		tmp = t_0;
	elseif (im <= -3e+20)
		tmp = t_2;
	elseif (im <= 5e+30)
		tmp = im * -cos(re);
	elseif (im <= 1.8e+96)
		tmp = t_2;
	elseif (im <= 7.5e+144)
		tmp = t_0;
	elseif (im <= 1.35e+154)
		tmp = (im * (0.5 * (re * re))) - im;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[im, -6.8e+143], t$95$1, If[LessEqual[im, -3.05e+92], t$95$0, If[LessEqual[im, -3e+20], t$95$2, If[LessEqual[im, 5e+30], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.8e+96], t$95$2, If[LessEqual[im, 7.5e+144], t$95$0, If[LessEqual[im, 1.35e+154], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$1]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
t_2 := \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot t_0\\
\mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -3.05 \cdot 10^{+92}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -3 \cdot 10^{+20}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq 5 \cdot 10^{+30}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+96}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -6.79999999999999964e143 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg100.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Applied egg-rr7.0%

      \[\leadsto \cos re \cdot \left(\color{blue}{-3} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.0%

        \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \cos re} \]
      2. flip--98.5%

        \[\leadsto \color{blue}{\frac{-3 \cdot -3 - im \cdot im}{-3 + im}} \cdot \cos re \]
      3. associate-*l/98.5%

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot -3 - im \cdot im\right) \cdot \cos re}{-3 + im}} \]
      4. metadata-eval98.5%

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative98.5%

        \[\leadsto \frac{\left(9 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3}} \]
    9. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\left(9 - im \cdot im\right) \cdot \cos re}{im + -3}} \]

    if -6.79999999999999964e143 < im < -3.04999999999999987e92 or 1.80000000000000007e96 < im < 7.5000000000000006e144

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 83.7%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg83.7%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg83.7%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative83.7%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*83.7%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--83.7%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified83.7%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 74.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -3.04999999999999987e92 < im < -3e20 or 4.9999999999999998e30 < im < 1.80000000000000007e96

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 5.1%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg5.1%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg5.1%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative5.1%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*5.1%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--5.1%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified5.1%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 43.3%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+43.3%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*43.3%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in43.3%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow243.3%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified43.3%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in re around inf 41.8%

      \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right)} \]
    11. Step-by-step derivation
      1. fma-neg41.8%

        \[\leadsto -0.5 \cdot \left({re}^{2} \cdot \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)}\right) \]
      2. associate-*r*41.8%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow241.8%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg41.8%

        \[\leadsto \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    12. Simplified41.8%

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

    if -3e20 < im < 4.9999999999999998e30

    1. Initial program 15.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg15.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 93.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg93.2%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative93.2%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in93.2%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified93.2%

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

    if 7.5000000000000006e144 < im < 1.35000000000000003e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 4.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg4.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative4.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in4.6%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified4.6%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 76.1%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-176.1%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative76.1%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg76.1%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative76.1%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative76.1%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*76.1%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow276.1%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified76.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+143}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -3.05 \cdot 10^{+92}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -3 \cdot 10^{+20}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+96}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+144}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 7: 83.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{if}\;im \leq -8 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -22:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          (+ (* -0.5 (* re re)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im)))
        (t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
   (if (<= im -8e+179)
     t_1
     (if (<= im -22.0)
       t_0
       (if (<= im 1.7e-7)
         (* im (- (cos re)))
         (if (<= im 1.35e+154) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -8e+179) {
		tmp = t_1;
	} else if (im <= -22.0) {
		tmp = t_0;
	} else if (im <= 1.7e-7) {
		tmp = im * -cos(re);
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((-0.5d0) * (re * re)) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
    if (im <= (-8d+179)) then
        tmp = t_1
    else if (im <= (-22.0d0)) then
        tmp = t_0
    else if (im <= 1.7d-7) then
        tmp = im * -cos(re)
    else if (im <= 1.35d+154) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double tmp;
	if (im <= -8e+179) {
		tmp = t_1;
	} else if (im <= -22.0) {
		tmp = t_0;
	} else if (im <= 1.7e-7) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((-0.5 * (re * re)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0)
	tmp = 0
	if im <= -8e+179:
		tmp = t_1
	elif im <= -22.0:
		tmp = t_0
	elif im <= 1.7e-7:
		tmp = im * -math.cos(re)
	elif im <= 1.35e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0))
	tmp = 0.0
	if (im <= -8e+179)
		tmp = t_1;
	elseif (im <= -22.0)
		tmp = t_0;
	elseif (im <= 1.7e-7)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((-0.5 * (re * re)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	tmp = 0.0;
	if (im <= -8e+179)
		tmp = t_1;
	elseif (im <= -22.0)
		tmp = t_0;
	elseif (im <= 1.7e-7)
		tmp = im * -cos(re);
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -8e+179], t$95$1, If[LessEqual[im, -22.0], t$95$0, If[LessEqual[im, 1.7e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -8 \cdot 10^{+179}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -22:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.99999999999999984e179 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg100.0%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Applied egg-rr7.1%

      \[\leadsto \cos re \cdot \left(\color{blue}{-3} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.1%

        \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \cos re} \]
      2. flip--100.0%

        \[\leadsto \color{blue}{\frac{-3 \cdot -3 - im \cdot im}{-3 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot -3 - im \cdot im\right) \cdot \cos re}{-3 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(9 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(9 - im \cdot im\right) \cdot \cos re}{im + -3}} \]

    if -7.99999999999999984e179 < im < -22 or 1.69999999999999987e-7 < im < 1.35000000000000003e154

    1. Initial program 99.1%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg99.1%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 43.1%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg43.1%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg43.1%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative43.1%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*43.1%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--43.1%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified43.1%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 22.4%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+22.4%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*22.4%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in49.9%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow249.9%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified49.9%

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

    if -22 < im < 1.69999999999999987e-7

    1. Initial program 8.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg8.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified8.4%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 99.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.4%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative99.4%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.4%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified99.4%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8 \cdot 10^{+179}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -22:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 8: 76.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{if}\;im \leq -1.55 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -5.8 \cdot 10^{+26}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
   (if (<= im -1.55e+102)
     t_0
     (if (<= im -5.8e+26)
       (* re (* re 0.75))
       (if (<= im 3.3e+30)
         (* im (- (cos re)))
         (if (<= im 2.8e+64) (- (* im (* 0.5 (* re re))) im) t_0))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double tmp;
	if (im <= -1.55e+102) {
		tmp = t_0;
	} else if (im <= -5.8e+26) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.3e+30) {
		tmp = im * -cos(re);
	} else if (im <= 2.8e+64) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    if (im <= (-1.55d+102)) then
        tmp = t_0
    else if (im <= (-5.8d+26)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 3.3d+30) then
        tmp = im * -cos(re)
    else if (im <= 2.8d+64) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double tmp;
	if (im <= -1.55e+102) {
		tmp = t_0;
	} else if (im <= -5.8e+26) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.3e+30) {
		tmp = im * -Math.cos(re);
	} else if (im <= 2.8e+64) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	tmp = 0
	if im <= -1.55e+102:
		tmp = t_0
	elif im <= -5.8e+26:
		tmp = re * (re * 0.75)
	elif im <= 3.3e+30:
		tmp = im * -math.cos(re)
	elif im <= 2.8e+64:
		tmp = (im * (0.5 * (re * re))) - im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	tmp = 0.0
	if (im <= -1.55e+102)
		tmp = t_0;
	elseif (im <= -5.8e+26)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 3.3e+30)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 2.8e+64)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	tmp = 0.0;
	if (im <= -1.55e+102)
		tmp = t_0;
	elseif (im <= -5.8e+26)
		tmp = re * (re * 0.75);
	elseif (im <= 3.3e+30)
		tmp = im * -cos(re);
	elseif (im <= 2.8e+64)
		tmp = (im * (0.5 * (re * re))) - im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -1.55e+102], t$95$0, If[LessEqual[im, -5.8e+26], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3e+30], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 2.8e+64], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -1.55 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -5.8 \cdot 10^{+26}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+30}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.54999999999999993e102 or 2.80000000000000024e64 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 93.8%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg93.8%

        \[\leadsto -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)} \]
      2. unsub-neg93.8%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im} \]
      3. *-commutative93.8%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im \]
      4. associate-*l*93.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--93.8%

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    6. Simplified93.8%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 72.9%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -1.54999999999999993e102 < im < -5.8e26

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out64.7%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow264.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*64.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified64.7%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr29.9%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 30.3%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative30.3%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow230.3%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*30.3%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified30.3%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -5.8e26 < im < 3.30000000000000026e30

    1. Initial program 15.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg15.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 92.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg92.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative92.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in92.6%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified92.6%

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

    if 3.30000000000000026e30 < im < 2.80000000000000024e64

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 3.5%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg3.5%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative3.5%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.5%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified3.5%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 67.0%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-167.0%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative67.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg67.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative67.0%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative67.0%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*67.0%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow267.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified67.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.55 \cdot 10^{+102}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -5.8 \cdot 10^{+26}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.8 \cdot 10^{+64}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 58.0% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -5.6e+24)
   (* re (* re 0.75))
   (if (<= im 3.7e+30) (* im (- (cos re))) (- (* im (* 0.5 (* re re))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.7e+30) {
		tmp = im * -cos(re);
	} else {
		tmp = (im * (0.5 * (re * re))) - im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-5.6d+24)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 3.7d+30) then
        tmp = im * -cos(re)
    else
        tmp = (im * (0.5d0 * (re * re))) - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.7e+30) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = (im * (0.5 * (re * re))) - im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -5.6e+24:
		tmp = re * (re * 0.75)
	elif im <= 3.7e+30:
		tmp = im * -math.cos(re)
	else:
		tmp = (im * (0.5 * (re * re))) - im
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -5.6e+24)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 3.7e+30)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -5.6e+24)
		tmp = re * (re * 0.75);
	elseif (im <= 3.7e+30)
		tmp = im * -cos(re);
	else
		tmp = (im * (0.5 * (re * re))) - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -5.6e+24], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.7e+30], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;im \leq 3.7 \cdot 10^{+30}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out68.9%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow268.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified68.9%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr16.0%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 16.6%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative16.6%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow216.6%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*16.6%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified16.6%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -5.6000000000000003e24 < im < 3.70000000000000016e30

    1. Initial program 15.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg15.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 92.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg92.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative92.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in92.6%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified92.6%

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

    if 3.70000000000000016e30 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 5.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg5.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative5.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in5.7%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified5.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 30.0%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-130.0%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative30.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg30.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative30.0%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative30.0%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*30.0%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow230.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified30.0%

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification60.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+30}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \]

Alternative 10: 36.4% accurate, 12.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot re\right) \cdot 0.75\\ \mathbf{if}\;re \leq 3.3 \cdot 10^{+77}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{2.25 - t_0 \cdot t_0}{-1.5 - t_0}\\ \mathbf{elif}\;re \leq 1.05 \cdot 10^{+229}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* re re) 0.75)))
   (if (<= re 3.3e+77)
     (- (* im (* 0.5 (* re re))) im)
     (if (<= re 1.35e+154)
       (/ (- 2.25 (* t_0 t_0)) (- -1.5 t_0))
       (if (<= re 1.05e+229)
         (* (+ 0.5 (* re (* re -0.25))) 27.0)
         (* re (* re 0.75)))))))
double code(double re, double im) {
	double t_0 = (re * re) * 0.75;
	double tmp;
	if (re <= 3.3e+77) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (re <= 1.35e+154) {
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	} else if (re <= 1.05e+229) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (re * re) * 0.75d0
    if (re <= 3.3d+77) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else if (re <= 1.35d+154) then
        tmp = (2.25d0 - (t_0 * t_0)) / ((-1.5d0) - t_0)
    else if (re <= 1.05d+229) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else
        tmp = re * (re * 0.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re * re) * 0.75;
	double tmp;
	if (re <= 3.3e+77) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (re <= 1.35e+154) {
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	} else if (re <= 1.05e+229) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
def code(re, im):
	t_0 = (re * re) * 0.75
	tmp = 0
	if re <= 3.3e+77:
		tmp = (im * (0.5 * (re * re))) - im
	elif re <= 1.35e+154:
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0)
	elif re <= 1.05e+229:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	else:
		tmp = re * (re * 0.75)
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re * re) * 0.75)
	tmp = 0.0
	if (re <= 3.3e+77)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	elseif (re <= 1.35e+154)
		tmp = Float64(Float64(2.25 - Float64(t_0 * t_0)) / Float64(-1.5 - t_0));
	elseif (re <= 1.05e+229)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	else
		tmp = Float64(re * Float64(re * 0.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re * re) * 0.75;
	tmp = 0.0;
	if (re <= 3.3e+77)
		tmp = (im * (0.5 * (re * re))) - im;
	elseif (re <= 1.35e+154)
		tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
	elseif (re <= 1.05e+229)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	else
		tmp = re * (re * 0.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]}, If[LessEqual[re, 3.3e+77], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(2.25 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.05e+229], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot 0.75\\
\mathbf{if}\;re \leq 3.3 \cdot 10^{+77}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\

\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{2.25 - t_0 \cdot t_0}{-1.5 - t_0}\\

\mathbf{elif}\;re \leq 1.05 \cdot 10^{+229}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if re < 3.2999999999999998e77

    1. Initial program 57.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg57.2%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified57.2%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 50.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg50.2%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative50.2%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in50.2%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified50.2%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 35.7%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-135.7%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative35.7%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg35.7%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative35.7%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative35.7%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*35.7%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow235.7%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified35.7%

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

    if 3.2999999999999998e77 < re < 1.35000000000000003e154

    1. Initial program 36.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg36.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified36.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 3.6%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative3.6%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*3.6%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out3.6%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative3.6%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative3.6%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow23.6%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*3.6%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified3.6%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr2.9%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Step-by-step derivation
      1. distribute-lft-in2.9%

        \[\leadsto \color{blue}{-3 \cdot 0.5 + -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      2. flip-+25.9%

        \[\leadsto \color{blue}{\frac{\left(-3 \cdot 0.5\right) \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
      3. metadata-eval25.9%

        \[\leadsto \frac{\color{blue}{-1.5} \cdot \left(-3 \cdot 0.5\right) - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      4. metadata-eval25.9%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{-1.5} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      5. metadata-eval25.9%

        \[\leadsto \frac{\color{blue}{2.25} - \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      6. *-commutative25.9%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)} \cdot \left(-3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      7. *-commutative25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right) \cdot \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      8. associate-*r*25.9%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      9. associate-*l*25.9%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)} \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      10. metadata-eval25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      11. associate-*r*25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      12. associate-*l*25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)\right)}}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      13. metadata-eval25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\right)}{-3 \cdot 0.5 - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      14. metadata-eval25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{\color{blue}{-1.5} - -3 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      15. *-commutative25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot -3}} \]
      16. associate-*r*25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot -3} \]
      17. associate-*l*25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\right)}} \]
      18. metadata-eval25.9%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot \color{blue}{0.75}} \]
    9. Applied egg-rr25.9%

      \[\leadsto \color{blue}{\frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot 0.75}} \]

    if 1.35000000000000003e154 < re < 1.04999999999999994e229

    1. Initial program 43.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg43.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified43.4%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out24.0%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow224.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified24.0%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr25.2%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]

    if 1.04999999999999994e229 < re

    1. Initial program 49.7%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg49.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified49.7%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.2%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.2%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out21.2%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow221.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified21.2%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr22.0%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 22.0%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative22.0%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow222.0%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*22.0%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified22.0%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification33.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 3.3 \cdot 10^{+77}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\right) \cdot \left(\left(re \cdot re\right) \cdot 0.75\right)}{-1.5 - \left(re \cdot re\right) \cdot 0.75}\\ \mathbf{elif}\;re \leq 1.05 \cdot 10^{+229}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

Alternative 11: 31.9% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.1 \cdot 10^{+155}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 7.6 \cdot 10^{+228}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.1e+155)
   (- im)
   (if (<= re 7.6e+228)
     (* (+ 0.5 (* re (* re -0.25))) 27.0)
     (* re (* re 0.75)))))
double code(double re, double im) {
	double tmp;
	if (re <= 1.1e+155) {
		tmp = -im;
	} else if (re <= 7.6e+228) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.1d+155) then
        tmp = -im
    else if (re <= 7.6d+228) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else
        tmp = re * (re * 0.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.1e+155) {
		tmp = -im;
	} else if (re <= 7.6e+228) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.1e+155:
		tmp = -im
	elif re <= 7.6e+228:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	else:
		tmp = re * (re * 0.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.1e+155)
		tmp = Float64(-im);
	elseif (re <= 7.6e+228)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	else
		tmp = Float64(re * Float64(re * 0.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.1e+155)
		tmp = -im;
	elseif (re <= 7.6e+228)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	else
		tmp = re * (re * 0.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.1e+155], (-im), If[LessEqual[re, 7.6e+228], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.1 \cdot 10^{+155}:\\
\;\;\;\;-im\\

\mathbf{elif}\;re \leq 7.6 \cdot 10^{+228}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < 1.1000000000000001e155

    1. Initial program 56.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg56.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 51.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg51.2%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative51.2%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in51.2%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified51.2%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 29.3%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-129.3%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified29.3%

      \[\leadsto \color{blue}{-im} \]

    if 1.1000000000000001e155 < re < 7.6000000000000004e228

    1. Initial program 43.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg43.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified43.4%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out24.0%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow224.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*24.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified24.0%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr25.2%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]

    if 7.6000000000000004e228 < re

    1. Initial program 49.7%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg49.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified49.7%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.2%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.2%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out21.2%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow221.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*21.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified21.2%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr22.0%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 22.0%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative22.0%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow222.0%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*22.0%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified22.0%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification28.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.1 \cdot 10^{+155}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 7.6 \cdot 10^{+228}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

Alternative 12: 35.9% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -5.6e+24)
   (* re (* re 0.75))
   (if (<= im 3.2e+30) (- im) (- (* im (* 0.5 (* re re))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.2e+30) {
		tmp = -im;
	} else {
		tmp = (im * (0.5 * (re * re))) - im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-5.6d+24)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 3.2d+30) then
        tmp = -im
    else
        tmp = (im * (0.5d0 * (re * re))) - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -5.6e+24) {
		tmp = re * (re * 0.75);
	} else if (im <= 3.2e+30) {
		tmp = -im;
	} else {
		tmp = (im * (0.5 * (re * re))) - im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -5.6e+24:
		tmp = re * (re * 0.75)
	elif im <= 3.2e+30:
		tmp = -im
	else:
		tmp = (im * (0.5 * (re * re))) - im
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -5.6e+24)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 3.2e+30)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -5.6e+24)
		tmp = re * (re * 0.75);
	elseif (im <= 3.2e+30)
		tmp = -im;
	else
		tmp = (im * (0.5 * (re * re))) - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -5.6e+24], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.2e+30], (-im), N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out68.9%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow268.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*68.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified68.9%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr16.0%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 16.6%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative16.6%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow216.6%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*16.6%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified16.6%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -5.6000000000000003e24 < im < 3.19999999999999973e30

    1. Initial program 15.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg15.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 92.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg92.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative92.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in92.6%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified92.6%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 44.2%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-144.2%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified44.2%

      \[\leadsto \color{blue}{-im} \]

    if 3.19999999999999973e30 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 5.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg5.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative5.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in5.7%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified5.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 30.0%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-130.0%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      2. +-commutative30.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      3. unsub-neg30.0%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative30.0%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      5. *-commutative30.0%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      6. associate-*l*30.0%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      7. unpow230.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified30.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+24}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+30}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \]

Alternative 13: 31.4% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 2 \cdot 10^{+166}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 2e+166) (- im) (* re (* re 0.75))))
double code(double re, double im) {
	double tmp;
	if (re <= 2e+166) {
		tmp = -im;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 2d+166) then
        tmp = -im
    else
        tmp = re * (re * 0.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 2e+166) {
		tmp = -im;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 2e+166:
		tmp = -im
	else:
		tmp = re * (re * 0.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 2e+166)
		tmp = Float64(-im);
	else
		tmp = Float64(re * Float64(re * 0.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 2e+166)
		tmp = -im;
	else
		tmp = re * (re * 0.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 2e+166], (-im), N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 2 \cdot 10^{+166}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.99999999999999988e166

    1. Initial program 56.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg56.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 50.8%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg50.8%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative50.8%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in50.8%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified50.8%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 28.6%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-128.6%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified28.6%

      \[\leadsto \color{blue}{-im} \]

    if 1.99999999999999988e166 < re

    1. Initial program 42.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg42.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified42.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.1%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.1%

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.1%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out16.8%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      4. +-commutative16.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      5. *-commutative16.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow216.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*16.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified16.8%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr23.2%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 23.2%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative23.2%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow223.2%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*23.2%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified23.2%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2 \cdot 10^{+166}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

Alternative 14: 29.6% accurate, 154.5× speedup?

\[\begin{array}{l} \\ -im \end{array} \]
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
	return -im;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -im
end function
public static double code(double re, double im) {
	return -im;
}
def code(re, im):
	return -im
function code(re, im)
	return Float64(-im)
end
function tmp = code(re, im)
	tmp = -im;
end
code[re_, im_] := (-im)
\begin{array}{l}

\\
-im
\end{array}
Derivation
  1. Initial program 54.3%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg54.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified54.3%

    \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
  4. Taylor expanded in im around 0 52.8%

    \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
  5. Step-by-step derivation
    1. mul-1-neg52.8%

      \[\leadsto \color{blue}{-\cos re \cdot im} \]
    2. *-commutative52.8%

      \[\leadsto -\color{blue}{im \cdot \cos re} \]
    3. distribute-lft-neg-in52.8%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  6. Simplified52.8%

    \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  7. Taylor expanded in re around 0 25.9%

    \[\leadsto \color{blue}{-1 \cdot im} \]
  8. Step-by-step derivation
    1. neg-mul-125.9%

      \[\leadsto \color{blue}{-im} \]
  9. Simplified25.9%

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification25.9%

    \[\leadsto -im \]

Alternative 15: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ -1.5 \end{array} \]
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
	return -1.5;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -1.5d0
end function
public static double code(double re, double im) {
	return -1.5;
}
def code(re, im):
	return -1.5
function code(re, im)
	return -1.5
end
function tmp = code(re, im)
	tmp = -1.5;
end
code[re_, im_] := -1.5
\begin{array}{l}

\\
-1.5
\end{array}
Derivation
  1. Initial program 54.3%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg54.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified54.3%

    \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
  4. Taylor expanded in re around 0 4.2%

    \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
  5. Step-by-step derivation
    1. *-commutative4.2%

      \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
    2. associate-*r*4.2%

      \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
    3. distribute-rgt-out39.7%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
    4. +-commutative39.7%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
    5. *-commutative39.7%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
    6. unpow239.7%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
    7. associate-*l*39.7%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
  6. Simplified39.7%

    \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
  7. Applied egg-rr9.0%

    \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
  8. Taylor expanded in re around 0 2.8%

    \[\leadsto \color{blue}{-1.5} \]
  9. Final simplification2.8%

    \[\leadsto -1.5 \]

Developer target: 99.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (< (fabs im) 1.0)
   (-
    (*
     (cos re)
     (+
      (+ im (* (* (* 0.16666666666666666 im) im) im))
      (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
   (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if (fabs(im) < 1.0) {
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (abs(im) < 1.0d0) then
        tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
    else
        tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.abs(im) < 1.0) {
		tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.fabs(im) < 1.0:
		tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
	else:
		tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (abs(im) < 1.0)
		tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (abs(im) < 1.0)
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	else
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023230 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))