math.sin on complex, imaginary part

Percentage Accurate: 53.8% → 99.3%
Time: 12.7s
Alternatives: 21
Speedup: 2.8×

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 21 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: 53.8% 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.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-14}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\cos re \cdot -0.16666666666666666\right) - im \cdot \cos re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-14)))
     (* (* 0.5 (cos re)) t_0)
     (- (* (pow im 3.0) (* (cos re) -0.16666666666666666)) (* im (cos re))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-14)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = (pow(im, 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e-14)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = (Math.pow(im, 3.0) * (Math.cos(re) * -0.16666666666666666)) - (im * Math.cos(re));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 5e-14):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = (math.pow(im, 3.0) * (math.cos(re) * -0.16666666666666666)) - (im * math.cos(re))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e-14))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(Float64((im ^ 3.0) * Float64(cos(re) * -0.16666666666666666)) - Float64(im * cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 5e-14)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = ((im ^ 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re));
	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, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-14]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0 or 5.0000000000000002e-14 < (-.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 -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000002e-14

    1. Initial program 7.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.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 99.9%

      \[\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.9%

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

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

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

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

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

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

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

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

Alternative 2: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-14}\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 (- INFINITY)) (not (<= t_0 5e-14)))
     (* (* 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 <= -((double) INFINITY)) || !(t_0 <= 5e-14)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e-14)) {
		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 <= -math.inf) or not (t_0 <= 5e-14):
		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 <= Float64(-Inf)) || !(t_0 <= 5e-14))
		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 <= -Inf) || ~((t_0 <= 5e-14)))
		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, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-14]], $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 -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-14}\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)) < -inf.0 or 5.0000000000000002e-14 < (-.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 -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000002e-14

    1. Initial program 7.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.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 99.9%

      \[\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.9%

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

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

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

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

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

      \[\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 -\infty \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-14}\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 3: 95.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.7 \cdot 10^{+101} \lor \neg \left(im \leq -0.07\right) \land \left(im \leq 0.039 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right)\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 -2.7e+101)
         (and (not (<= im -0.07)) (or (<= im 0.039) (not (<= im 5.5e+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 <= -2.7e+101) || (!(im <= -0.07) && ((im <= 0.039) || !(im <= 5.5e+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 <= (-2.7d+101)) .or. (.not. (im <= (-0.07d0))) .and. (im <= 0.039d0) .or. (.not. (im <= 5.5d+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 <= -2.7e+101) || (!(im <= -0.07) && ((im <= 0.039) || !(im <= 5.5e+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 <= -2.7e+101) or (not (im <= -0.07) and ((im <= 0.039) or not (im <= 5.5e+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 <= -2.7e+101) || (!(im <= -0.07) && ((im <= 0.039) || !(im <= 5.5e+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 <= -2.7e+101) || (~((im <= -0.07)) && ((im <= 0.039) || ~((im <= 5.5e+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, -2.7e+101], And[N[Not[LessEqual[im, -0.07]], $MachinePrecision], Or[LessEqual[im, 0.039], N[Not[LessEqual[im, 5.5e+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 -2.7 \cdot 10^{+101} \lor \neg \left(im \leq -0.07\right) \land \left(im \leq 0.039 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right)\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 < -2.70000000000000006e101 or -0.070000000000000007 < im < 0.0389999999999999999 or 5.49999999999999981e102 < im

    1. Initial program 46.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified46.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 99.5%

      \[\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.5%

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

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

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

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

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

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

    if -2.70000000000000006e101 < im < -0.070000000000000007 or 0.0389999999999999999 < im < 5.49999999999999981e102

    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 81.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.7 \cdot 10^{+101} \lor \neg \left(im \leq -0.07\right) \land \left(im \leq 0.039 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right)\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: 87.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;im \leq -0.00035:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00355:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right) \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 (* 0.5 (- (exp (- im)) (exp im)))))
   (if (<= im -0.00035)
     t_0
     (if (<= im 0.00355)
       (* im (- (cos re)))
       (if (<= im 1e+139)
         t_0
         (*
          (+ (* im -2.0) (* (pow im 3.0) -0.3333333333333333))
          (+ 0.5 (* re (* re -0.25)))))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double tmp;
	if (im <= -0.00035) {
		tmp = t_0;
	} else if (im <= 0.00355) {
		tmp = im * -cos(re);
	} else if (im <= 1e+139) {
		tmp = t_0;
	} else {
		tmp = ((im * -2.0) + (pow(im, 3.0) * -0.3333333333333333)) * (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) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    if (im <= (-0.00035d0)) then
        tmp = t_0
    else if (im <= 0.00355d0) then
        tmp = im * -cos(re)
    else if (im <= 1d+139) then
        tmp = t_0
    else
        tmp = ((im * (-2.0d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0))) * (0.5d0 + (re * (re * (-0.25d0))))
    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 tmp;
	if (im <= -0.00035) {
		tmp = t_0;
	} else if (im <= 0.00355) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1e+139) {
		tmp = t_0;
	} else {
		tmp = ((im * -2.0) + (Math.pow(im, 3.0) * -0.3333333333333333)) * (0.5 + (re * (re * -0.25)));
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	tmp = 0
	if im <= -0.00035:
		tmp = t_0
	elif im <= 0.00355:
		tmp = im * -math.cos(re)
	elif im <= 1e+139:
		tmp = t_0
	else:
		tmp = ((im * -2.0) + (math.pow(im, 3.0) * -0.3333333333333333)) * (0.5 + (re * (re * -0.25)))
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (im <= -0.00035)
		tmp = t_0;
	elseif (im <= 0.00355)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1e+139)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(im * -2.0) + Float64((im ^ 3.0) * -0.3333333333333333)) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	tmp = 0.0;
	if (im <= -0.00035)
		tmp = t_0;
	elseif (im <= 0.00355)
		tmp = im * -cos(re);
	elseif (im <= 1e+139)
		tmp = t_0;
	else
		tmp = ((im * -2.0) + ((im ^ 3.0) * -0.3333333333333333)) * (0.5 + (re * (re * -0.25)));
	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]}, If[LessEqual[im, -0.00035], t$95$0, If[LessEqual[im, 0.00355], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1e+139], t$95$0, N[(N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;im \leq -0.00035:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 10^{+139}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right) \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.49999999999999996e-4 or 0.0035500000000000002 < im < 1.00000000000000003e139

    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 84.0%

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

    if -3.49999999999999996e-4 < im < 0.0035500000000000002

    1. Initial program 7.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified7.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 99.7%

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

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

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

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

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

    if 1.00000000000000003e139 < 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 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-out87.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow287.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*87.2%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.00035:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.00355:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 10^{+139}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 5: 75.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.3333333333333333\\ \mathbf{if}\;im \leq -1 \cdot 10^{+166}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -21500000:\\ \;\;\;\;t_0 \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot -2 + t_0\right) \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 (* (pow im 3.0) -0.3333333333333333)))
   (if (<= im -1e+166)
     (* (pow im 3.0) -0.16666666666666666)
     (if (<= im -21500000.0)
       (* t_0 (+ 0.5 (* -0.25 (* re re))))
       (if (<= im 4.2e-7)
         (* im (- (cos re)))
         (if (<= im 7.5e+138)
           (-
            (* im (+ (* re (* 0.5 re)) (* (pow re 4.0) -0.041666666666666664)))
            im)
           (* (+ (* im -2.0) t_0) (+ 0.5 (* re (* re -0.25))))))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.3333333333333333;
	double tmp;
	if (im <= -1e+166) {
		tmp = pow(im, 3.0) * -0.16666666666666666;
	} else if (im <= -21500000.0) {
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	} else if (im <= 4.2e-7) {
		tmp = im * -cos(re);
	} else if (im <= 7.5e+138) {
		tmp = (im * ((re * (0.5 * re)) + (pow(re, 4.0) * -0.041666666666666664))) - im;
	} else {
		tmp = ((im * -2.0) + 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) :: tmp
    t_0 = (im ** 3.0d0) * (-0.3333333333333333d0)
    if (im <= (-1d+166)) then
        tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
    else if (im <= (-21500000.0d0)) then
        tmp = t_0 * (0.5d0 + ((-0.25d0) * (re * re)))
    else if (im <= 4.2d-7) then
        tmp = im * -cos(re)
    else if (im <= 7.5d+138) then
        tmp = (im * ((re * (0.5d0 * re)) + ((re ** 4.0d0) * (-0.041666666666666664d0)))) - im
    else
        tmp = ((im * (-2.0d0)) + 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.pow(im, 3.0) * -0.3333333333333333;
	double tmp;
	if (im <= -1e+166) {
		tmp = Math.pow(im, 3.0) * -0.16666666666666666;
	} else if (im <= -21500000.0) {
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	} else if (im <= 4.2e-7) {
		tmp = im * -Math.cos(re);
	} else if (im <= 7.5e+138) {
		tmp = (im * ((re * (0.5 * re)) + (Math.pow(re, 4.0) * -0.041666666666666664))) - im;
	} else {
		tmp = ((im * -2.0) + t_0) * (0.5 + (re * (re * -0.25)));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.3333333333333333
	tmp = 0
	if im <= -1e+166:
		tmp = math.pow(im, 3.0) * -0.16666666666666666
	elif im <= -21500000.0:
		tmp = t_0 * (0.5 + (-0.25 * (re * re)))
	elif im <= 4.2e-7:
		tmp = im * -math.cos(re)
	elif im <= 7.5e+138:
		tmp = (im * ((re * (0.5 * re)) + (math.pow(re, 4.0) * -0.041666666666666664))) - im
	else:
		tmp = ((im * -2.0) + t_0) * (0.5 + (re * (re * -0.25)))
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.3333333333333333)
	tmp = 0.0
	if (im <= -1e+166)
		tmp = Float64((im ^ 3.0) * -0.16666666666666666);
	elseif (im <= -21500000.0)
		tmp = Float64(t_0 * Float64(0.5 + Float64(-0.25 * Float64(re * re))));
	elseif (im <= 4.2e-7)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 7.5e+138)
		tmp = Float64(Float64(im * Float64(Float64(re * Float64(0.5 * re)) + Float64((re ^ 4.0) * -0.041666666666666664))) - im);
	else
		tmp = Float64(Float64(Float64(im * -2.0) + t_0) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.3333333333333333;
	tmp = 0.0;
	if (im <= -1e+166)
		tmp = (im ^ 3.0) * -0.16666666666666666;
	elseif (im <= -21500000.0)
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	elseif (im <= 4.2e-7)
		tmp = im * -cos(re);
	elseif (im <= 7.5e+138)
		tmp = (im * ((re * (0.5 * re)) + ((re ^ 4.0) * -0.041666666666666664))) - im;
	else
		tmp = ((im * -2.0) + t_0) * (0.5 + (re * (re * -0.25)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, If[LessEqual[im, -1e+166], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], If[LessEqual[im, -21500000.0], N[(t$95$0 * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 7.5e+138], N[(N[(im * N[(N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision] + N[(N[Power[re, 4.0], $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(N[(N[(im * -2.0), $MachinePrecision] + t$95$0), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -21500000:\\
\;\;\;\;t_0 \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\

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

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -9.9999999999999994e165

    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-out73.1%

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

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

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

        \[\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*73.1%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 73.1%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*73.1%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified73.1%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 92.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative92.3%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified92.3%

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

    if -9.9999999999999994e165 < im < -2.15e7

    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-out77.3%

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

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

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

        \[\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*77.3%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 40.9%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*40.9%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified40.9%

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

    if -2.15e7 < im < 4.2e-7

    1. Initial program 8.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified8.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 98.2%

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

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

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

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

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

    if 4.2e-7 < im < 7.4999999999999999e138

    1. Initial program 99.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.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 6.6%

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

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

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

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

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

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

        \[\leadsto -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(\color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right)\right) \]
      2. associate-+r+21.9%

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

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

        \[\leadsto 0.5 \cdot \left({re}^{2} \cdot im\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) - im\right)} \]
      5. associate-+r-21.9%

        \[\leadsto \color{blue}{\left(0.5 \cdot \left({re}^{2} \cdot im\right) + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im} \]
      6. associate-*r*21.9%

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

        \[\leadsto \left(\left(0.5 \cdot {re}^{2}\right) \cdot im + \color{blue}{\left(-0.041666666666666664 \cdot {re}^{4}\right) \cdot im}\right) - im \]
      8. distribute-rgt-out28.8%

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      11. associate-*l*28.8%

        \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(re \cdot 0.5\right)} + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      12. *-commutative28.8%

        \[\leadsto im \cdot \left(re \cdot \left(re \cdot 0.5\right) + \color{blue}{{re}^{4} \cdot -0.041666666666666664}\right) - im \]
    9. Simplified28.8%

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

    if 7.4999999999999999e138 < 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 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-out87.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow287.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*87.2%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+166}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -21500000:\\ \;\;\;\;\left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 6: 75.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{if}\;im \leq -4 \cdot 10^{+163}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -54000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (* (* (pow im 3.0) -0.3333333333333333) (+ 0.5 (* -0.25 (* re re))))))
   (if (<= im -4e+163)
     (* (pow im 3.0) -0.16666666666666666)
     (if (<= im -54000000.0)
       t_0
       (if (<= im 4.2e-7)
         (* im (- (cos re)))
         (if (<= im 7.5e+138)
           (-
            (* im (+ (* re (* 0.5 re)) (* (pow re 4.0) -0.041666666666666664)))
            im)
           t_0))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	double tmp;
	if (im <= -4e+163) {
		tmp = pow(im, 3.0) * -0.16666666666666666;
	} else if (im <= -54000000.0) {
		tmp = t_0;
	} else if (im <= 4.2e-7) {
		tmp = im * -cos(re);
	} else if (im <= 7.5e+138) {
		tmp = (im * ((re * (0.5 * re)) + (pow(re, 4.0) * -0.041666666666666664))) - 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.3333333333333333d0)) * (0.5d0 + ((-0.25d0) * (re * re)))
    if (im <= (-4d+163)) then
        tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
    else if (im <= (-54000000.0d0)) then
        tmp = t_0
    else if (im <= 4.2d-7) then
        tmp = im * -cos(re)
    else if (im <= 7.5d+138) then
        tmp = (im * ((re * (0.5d0 * re)) + ((re ** 4.0d0) * (-0.041666666666666664d0)))) - 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.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	double tmp;
	if (im <= -4e+163) {
		tmp = Math.pow(im, 3.0) * -0.16666666666666666;
	} else if (im <= -54000000.0) {
		tmp = t_0;
	} else if (im <= 4.2e-7) {
		tmp = im * -Math.cos(re);
	} else if (im <= 7.5e+138) {
		tmp = (im * ((re * (0.5 * re)) + (Math.pow(re, 4.0) * -0.041666666666666664))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)))
	tmp = 0
	if im <= -4e+163:
		tmp = math.pow(im, 3.0) * -0.16666666666666666
	elif im <= -54000000.0:
		tmp = t_0
	elif im <= 4.2e-7:
		tmp = im * -math.cos(re)
	elif im <= 7.5e+138:
		tmp = (im * ((re * (0.5 * re)) + (math.pow(re, 4.0) * -0.041666666666666664))) - im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.3333333333333333) * Float64(0.5 + Float64(-0.25 * Float64(re * re))))
	tmp = 0.0
	if (im <= -4e+163)
		tmp = Float64((im ^ 3.0) * -0.16666666666666666);
	elseif (im <= -54000000.0)
		tmp = t_0;
	elseif (im <= 4.2e-7)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 7.5e+138)
		tmp = Float64(Float64(im * Float64(Float64(re * Float64(0.5 * re)) + Float64((re ^ 4.0) * -0.041666666666666664))) - im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	tmp = 0.0;
	if (im <= -4e+163)
		tmp = (im ^ 3.0) * -0.16666666666666666;
	elseif (im <= -54000000.0)
		tmp = t_0;
	elseif (im <= 4.2e-7)
		tmp = im * -cos(re);
	elseif (im <= 7.5e+138)
		tmp = (im * ((re * (0.5 * re)) + ((re ^ 4.0) * -0.041666666666666664))) - 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.3333333333333333), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4e+163], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], If[LessEqual[im, -54000000.0], t$95$0, If[LessEqual[im, 4.2e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 7.5e+138], N[(N[(im * N[(N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision] + N[(N[Power[re, 4.0], $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -4 \cdot 10^{+163}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\

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

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

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.9999999999999998e163

    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-out73.1%

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

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

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

        \[\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*73.1%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 73.1%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*73.1%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified73.1%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 92.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative92.3%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified92.3%

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

    if -3.9999999999999998e163 < im < -5.4e7 or 7.4999999999999999e138 < 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 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-out81.9%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow281.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*81.9%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 62.6%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*62.6%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified62.6%

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

    if -5.4e7 < im < 4.2e-7

    1. Initial program 8.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified8.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 98.2%

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

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

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

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

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

    if 4.2e-7 < im < 7.4999999999999999e138

    1. Initial program 99.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.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 6.6%

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

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

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

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

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

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

        \[\leadsto -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(\color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right)\right) \]
      2. associate-+r+21.9%

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

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

        \[\leadsto 0.5 \cdot \left({re}^{2} \cdot im\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) - im\right)} \]
      5. associate-+r-21.9%

        \[\leadsto \color{blue}{\left(0.5 \cdot \left({re}^{2} \cdot im\right) + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im} \]
      6. associate-*r*21.9%

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

        \[\leadsto \left(\left(0.5 \cdot {re}^{2}\right) \cdot im + \color{blue}{\left(-0.041666666666666664 \cdot {re}^{4}\right) \cdot im}\right) - im \]
      8. distribute-rgt-out28.8%

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      11. associate-*l*28.8%

        \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(re \cdot 0.5\right)} + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      12. *-commutative28.8%

        \[\leadsto im \cdot \left(re \cdot \left(re \cdot 0.5\right) + \color{blue}{{re}^{4} \cdot -0.041666666666666664}\right) - im \]
    9. Simplified28.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4 \cdot 10^{+163}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -54000000:\\ \;\;\;\;\left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+138}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + {re}^{4} \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

Alternative 7: 76.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{if}\;im \leq -3.8 \cdot 10^{+167}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -21500000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 10^{+139}:\\ \;\;\;\;t_0 - im\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (* (* (pow im 3.0) -0.3333333333333333) (+ 0.5 (* -0.25 (* re re))))))
   (if (<= im -3.8e+167)
     t_0
     (if (<= im -21500000.0)
       t_1
       (if (<= im 4.2e-7)
         (* im (- (cos re)))
         (if (<= im 1e+139) (- t_0 im) t_1))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (pow(im, 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	double tmp;
	if (im <= -3.8e+167) {
		tmp = t_0;
	} else if (im <= -21500000.0) {
		tmp = t_1;
	} else if (im <= 4.2e-7) {
		tmp = im * -cos(re);
	} else if (im <= 1e+139) {
		tmp = t_0 - 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) :: tmp
    t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = ((im ** 3.0d0) * (-0.3333333333333333d0)) * (0.5d0 + ((-0.25d0) * (re * re)))
    if (im <= (-3.8d+167)) then
        tmp = t_0
    else if (im <= (-21500000.0d0)) then
        tmp = t_1
    else if (im <= 4.2d-7) then
        tmp = im * -cos(re)
    else if (im <= 1d+139) then
        tmp = t_0 - 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;
	double t_1 = (Math.pow(im, 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	double tmp;
	if (im <= -3.8e+167) {
		tmp = t_0;
	} else if (im <= -21500000.0) {
		tmp = t_1;
	} else if (im <= 4.2e-7) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1e+139) {
		tmp = t_0 - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (math.pow(im, 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)))
	tmp = 0
	if im <= -3.8e+167:
		tmp = t_0
	elif im <= -21500000.0:
		tmp = t_1
	elif im <= 4.2e-7:
		tmp = im * -math.cos(re)
	elif im <= 1e+139:
		tmp = t_0 - im
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64((im ^ 3.0) * -0.3333333333333333) * Float64(0.5 + Float64(-0.25 * Float64(re * re))))
	tmp = 0.0
	if (im <= -3.8e+167)
		tmp = t_0;
	elseif (im <= -21500000.0)
		tmp = t_1;
	elseif (im <= 4.2e-7)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1e+139)
		tmp = Float64(t_0 - im);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = ((im ^ 3.0) * -0.3333333333333333) * (0.5 + (-0.25 * (re * re)));
	tmp = 0.0;
	if (im <= -3.8e+167)
		tmp = t_0;
	elseif (im <= -21500000.0)
		tmp = t_1;
	elseif (im <= 4.2e-7)
		tmp = im * -cos(re);
	elseif (im <= 1e+139)
		tmp = t_0 - im;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.8e+167], t$95$0, If[LessEqual[im, -21500000.0], t$95$1, If[LessEqual[im, 4.2e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1e+139], N[(t$95$0 - im), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -3.8 \cdot 10^{+167}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -21500000:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 10^{+139}:\\
\;\;\;\;t_0 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.79999999999999994e167

    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-out73.1%

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

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

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

        \[\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*73.1%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 73.1%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*73.1%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified73.1%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 92.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative92.3%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified92.3%

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

    if -3.79999999999999994e167 < im < -2.15e7 or 1.00000000000000003e139 < 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 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-out81.9%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow281.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*81.9%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 62.6%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*62.6%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified62.6%

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

    if -2.15e7 < im < 4.2e-7

    1. Initial program 8.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified8.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 98.2%

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

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

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

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

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

    if 4.2e-7 < im < 1.00000000000000003e139

    1. Initial program 99.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.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 28.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-neg28.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification78.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.8 \cdot 10^{+167}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -21500000:\\ \;\;\;\;\left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 10^{+139}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.3333333333333333\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

Alternative 8: 38.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\ t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\ \mathbf{if}\;im \leq -3 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1.52 \cdot 10^{+55}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+220}:\\ \;\;\;\;{im}^{3} \cdot 0.0625\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* -0.25 (* re re))))
        (t_1 (/ (- (* im im) (* 4.0 (* t_0 t_0))) (- (- im) (* -2.0 t_0)))))
   (if (<= im -3e+25)
     t_1
     (if (<= im 1.52e+55)
       (- (* re (* re (* im 0.5))) im)
       (if (<= im 9.5e+139)
         (* (+ 0.5 (* re (* re -0.25))) 27.0)
         (if (<= im 8e+220) (* (pow im 3.0) 0.0625) t_1))))))
double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -3e+25) {
		tmp = t_1;
	} else if (im <= 1.52e+55) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 9.5e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 8e+220) {
		tmp = pow(im, 3.0) * 0.0625;
	} 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 = im * ((-0.25d0) * (re * re))
    t_1 = ((im * im) - (4.0d0 * (t_0 * t_0))) / (-im - ((-2.0d0) * t_0))
    if (im <= (-3d+25)) then
        tmp = t_1
    else if (im <= 1.52d+55) then
        tmp = (re * (re * (im * 0.5d0))) - im
    else if (im <= 9.5d+139) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else if (im <= 8d+220) then
        tmp = (im ** 3.0d0) * 0.0625d0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -3e+25) {
		tmp = t_1;
	} else if (im <= 1.52e+55) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 9.5e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 8e+220) {
		tmp = Math.pow(im, 3.0) * 0.0625;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (-0.25 * (re * re))
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0))
	tmp = 0
	if im <= -3e+25:
		tmp = t_1
	elif im <= 1.52e+55:
		tmp = (re * (re * (im * 0.5))) - im
	elif im <= 9.5e+139:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	elif im <= 8e+220:
		tmp = math.pow(im, 3.0) * 0.0625
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(-0.25 * Float64(re * re)))
	t_1 = Float64(Float64(Float64(im * im) - Float64(4.0 * Float64(t_0 * t_0))) / Float64(Float64(-im) - Float64(-2.0 * t_0)))
	tmp = 0.0
	if (im <= -3e+25)
		tmp = t_1;
	elseif (im <= 1.52e+55)
		tmp = Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im);
	elseif (im <= 9.5e+139)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	elseif (im <= 8e+220)
		tmp = Float64((im ^ 3.0) * 0.0625);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (-0.25 * (re * re));
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	tmp = 0.0;
	if (im <= -3e+25)
		tmp = t_1;
	elseif (im <= 1.52e+55)
		tmp = (re * (re * (im * 0.5))) - im;
	elseif (im <= 9.5e+139)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	elseif (im <= 8e+220)
		tmp = (im ^ 3.0) * 0.0625;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(im * im), $MachinePrecision] - N[(4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-im) - N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3e+25], t$95$1, If[LessEqual[im, 1.52e+55], N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 9.5e+139], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], If[LessEqual[im, 8e+220], N[(N[Power[im, 3.0], $MachinePrecision] * 0.0625), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\
\mathbf{if}\;im \leq -3 \cdot 10^{+25}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 8 \cdot 10^{+220}:\\
\;\;\;\;{im}^{3} \cdot 0.0625\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.00000000000000006e25 or 8e220 < 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 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-out82.3%

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

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

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

        \[\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*82.3%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 18.0%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(-2 \cdot im\right) \cdot 0.5\right) \cdot \left(\left(-2 \cdot im\right) \cdot 0.5\right) - \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{\left(-2 \cdot im\right) \cdot 0.5 - \left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
    9. Applied egg-rr39.1%

      \[\leadsto \color{blue}{\frac{\left(im \cdot -1\right) \cdot \left(im \cdot -1\right) - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. swap-sqr39.1%

        \[\leadsto \frac{\color{blue}{\left(im \cdot im\right) \cdot \left(-1 \cdot -1\right)} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      2. metadata-eval39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot \color{blue}{1} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      3. swap-sqr39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{\left(-2 \cdot -2\right) \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      4. metadata-eval39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{4} \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      5. *-commutative39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{-1 \cdot im} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. mul-1-neg39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{\left(-im\right)} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
    11. Simplified39.1%

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

    if -3.00000000000000006e25 < im < 1.5200000000000001e55

    1. Initial program 21.4%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified21.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 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(--0.5 \cdot im\right) - im \]
      10. associate-*l*52.1%

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

        \[\leadsto re \cdot \left(re \cdot \left(-\color{blue}{im \cdot -0.5}\right)\right) - im \]
      12. distribute-rgt-neg-in52.1%

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

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

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

    if 1.5200000000000001e55 < im < 9.5000000000000002e139

    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-out41.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow241.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*41.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified41.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-rr37.1%

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

    if 9.5000000000000002e139 < im < 8e220

    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 -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \color{blue}{im \cdot \cos re} \]
      4. *-commutative100.0%

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

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

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

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

      \[\leadsto {im}^{3} \cdot \color{blue}{0.0625} - im \cdot \cos re \]
    8. Taylor expanded in im around inf 50.0%

      \[\leadsto \color{blue}{0.0625 \cdot {im}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification46.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3 \cdot 10^{+25}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \mathbf{elif}\;im \leq 1.52 \cdot 10^{+55}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+220}:\\ \;\;\;\;{im}^{3} \cdot 0.0625\\ \mathbf{else}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \end{array} \]

Alternative 9: 62.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\ t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\ \mathbf{if}\;im \leq -4.8 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 2.35 \cdot 10^{+51}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.8 \cdot 10^{+138}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+221}:\\ \;\;\;\;{im}^{3} \cdot 0.0625\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* -0.25 (* re re))))
        (t_1 (/ (- (* im im) (* 4.0 (* t_0 t_0))) (- (- im) (* -2.0 t_0)))))
   (if (<= im -4.8e+23)
     t_1
     (if (<= im 2.35e+51)
       (* im (- (cos re)))
       (if (<= im 7.8e+138)
         (* (+ 0.5 (* re (* re -0.25))) 27.0)
         (if (<= im 1.35e+221) (* (pow im 3.0) 0.0625) t_1))))))
double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -4.8e+23) {
		tmp = t_1;
	} else if (im <= 2.35e+51) {
		tmp = im * -cos(re);
	} else if (im <= 7.8e+138) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 1.35e+221) {
		tmp = pow(im, 3.0) * 0.0625;
	} 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 = im * ((-0.25d0) * (re * re))
    t_1 = ((im * im) - (4.0d0 * (t_0 * t_0))) / (-im - ((-2.0d0) * t_0))
    if (im <= (-4.8d+23)) then
        tmp = t_1
    else if (im <= 2.35d+51) then
        tmp = im * -cos(re)
    else if (im <= 7.8d+138) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else if (im <= 1.35d+221) then
        tmp = (im ** 3.0d0) * 0.0625d0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -4.8e+23) {
		tmp = t_1;
	} else if (im <= 2.35e+51) {
		tmp = im * -Math.cos(re);
	} else if (im <= 7.8e+138) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 1.35e+221) {
		tmp = Math.pow(im, 3.0) * 0.0625;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (-0.25 * (re * re))
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0))
	tmp = 0
	if im <= -4.8e+23:
		tmp = t_1
	elif im <= 2.35e+51:
		tmp = im * -math.cos(re)
	elif im <= 7.8e+138:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	elif im <= 1.35e+221:
		tmp = math.pow(im, 3.0) * 0.0625
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(-0.25 * Float64(re * re)))
	t_1 = Float64(Float64(Float64(im * im) - Float64(4.0 * Float64(t_0 * t_0))) / Float64(Float64(-im) - Float64(-2.0 * t_0)))
	tmp = 0.0
	if (im <= -4.8e+23)
		tmp = t_1;
	elseif (im <= 2.35e+51)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 7.8e+138)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	elseif (im <= 1.35e+221)
		tmp = Float64((im ^ 3.0) * 0.0625);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (-0.25 * (re * re));
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	tmp = 0.0;
	if (im <= -4.8e+23)
		tmp = t_1;
	elseif (im <= 2.35e+51)
		tmp = im * -cos(re);
	elseif (im <= 7.8e+138)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	elseif (im <= 1.35e+221)
		tmp = (im ^ 3.0) * 0.0625;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(im * im), $MachinePrecision] - N[(4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-im) - N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.8e+23], t$95$1, If[LessEqual[im, 2.35e+51], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 7.8e+138], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], If[LessEqual[im, 1.35e+221], N[(N[Power[im, 3.0], $MachinePrecision] * 0.0625), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\
\mathbf{if}\;im \leq -4.8 \cdot 10^{+23}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+221}:\\
\;\;\;\;{im}^{3} \cdot 0.0625\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -4.8e23 or 1.35e221 < 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 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-out82.5%

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

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

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

        \[\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*82.5%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 17.8%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(-2 \cdot im\right) \cdot 0.5\right) \cdot \left(\left(-2 \cdot im\right) \cdot 0.5\right) - \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{\left(-2 \cdot im\right) \cdot 0.5 - \left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
    9. Applied egg-rr38.6%

      \[\leadsto \color{blue}{\frac{\left(im \cdot -1\right) \cdot \left(im \cdot -1\right) - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. swap-sqr38.6%

        \[\leadsto \frac{\color{blue}{\left(im \cdot im\right) \cdot \left(-1 \cdot -1\right)} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      2. metadata-eval38.6%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot \color{blue}{1} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      3. swap-sqr38.6%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{\left(-2 \cdot -2\right) \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      4. metadata-eval38.6%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{4} \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      5. *-commutative38.6%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{-1 \cdot im} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. mul-1-neg38.6%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{\left(-im\right)} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
    11. Simplified38.6%

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

    if -4.8e23 < im < 2.3500000000000001e51

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

    if 2.3500000000000001e51 < im < 7.7999999999999996e138

    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-out41.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow241.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*41.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified41.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-rr37.1%

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

    if 7.7999999999999996e138 < im < 1.35e221

    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 -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \color{blue}{im \cdot \cos re} \]
      4. *-commutative100.0%

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

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

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

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

      \[\leadsto {im}^{3} \cdot \color{blue}{0.0625} - im \cdot \cos re \]
    8. Taylor expanded in im around inf 50.0%

      \[\leadsto \color{blue}{0.0625 \cdot {im}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification64.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.8 \cdot 10^{+23}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \mathbf{elif}\;im \leq 2.35 \cdot 10^{+51}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.8 \cdot 10^{+138}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+221}:\\ \;\;\;\;{im}^{3} \cdot 0.0625\\ \mathbf{else}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \end{array} \]

Alternative 10: 75.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -2.4 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -2.4e+89)
     t_0
     (if (<= im -1.18e+44)
       (/
        (- 2.25 (* (* (* re re) (* re re)) 0.5625))
        (- -1.5 (* re (* re 0.75))))
       (if (<= im 4.2e-7) (* im (- (cos re))) (- t_0 im))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -2.4e+89) {
		tmp = t_0;
	} else if (im <= -1.18e+44) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	} else if (im <= 4.2e-7) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0 - 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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-2.4d+89)) then
        tmp = t_0
    else if (im <= (-1.18d+44)) then
        tmp = (2.25d0 - (((re * re) * (re * re)) * 0.5625d0)) / ((-1.5d0) - (re * (re * 0.75d0)))
    else if (im <= 4.2d-7) then
        tmp = im * -cos(re)
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -2.4e+89) {
		tmp = t_0;
	} else if (im <= -1.18e+44) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	} else if (im <= 4.2e-7) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -2.4e+89:
		tmp = t_0
	elif im <= -1.18e+44:
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)))
	elif im <= 4.2e-7:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -2.4e+89)
		tmp = t_0;
	elseif (im <= -1.18e+44)
		tmp = Float64(Float64(2.25 - Float64(Float64(Float64(re * re) * Float64(re * re)) * 0.5625)) / Float64(-1.5 - Float64(re * Float64(re * 0.75))));
	elseif (im <= 4.2e-7)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -2.4e+89)
		tmp = t_0;
	elseif (im <= -1.18e+44)
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	elseif (im <= 4.2e-7)
		tmp = im * -cos(re);
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -2.4e+89], t$95$0, If[LessEqual[im, -1.18e+44], N[(N[(2.25 - N[(N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] * 0.5625), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\
\;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.40000000000000004e89

    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-out79.1%

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

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

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

        \[\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*79.1%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 72.8%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*72.8%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified72.8%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 79.7%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative79.7%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified79.7%

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

    if -2.40000000000000004e89 < im < -1.17999999999999997e44

    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-out61.5%

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

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

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

        \[\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*61.5%

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

      \[\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-rr3.2%

      \[\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-in3.2%

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

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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. *-commutative38.8%

        \[\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. associate-*r*38.8%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\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)} \]
      8. associate-*l*38.8%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\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)} \]
      9. metadata-eval38.8%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\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)} \]
      10. *-commutative38.8%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\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)} \]
      11. associate-*r*38.8%

        \[\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*38.8%

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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. *-commutative38.8%

        \[\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*38.8%

        \[\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*38.8%

        \[\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-eval38.8%

        \[\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-rr38.8%

      \[\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}} \]
    10. Step-by-step derivation
      1. swap-sqr38.8%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot \left(0.75 \cdot 0.75\right)}}{-1.5 - \left(re \cdot re\right) \cdot 0.75} \]
      2. metadata-eval38.8%

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

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - \color{blue}{re \cdot \left(re \cdot 0.75\right)}} \]
    11. Simplified38.8%

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

    if -1.17999999999999997e44 < im < 4.2e-7

    1. Initial program 18.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified18.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 88.1%

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

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

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

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

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

    if 4.2e-7 < im

    1. Initial program 99.6%

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

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

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

      \[\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-neg69.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification72.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.4 \cdot 10^{+89}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 11: 76.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -3.5 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -720:\\ \;\;\;\;\left|im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\right|\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -3.5e+91)
     t_0
     (if (<= im -720.0)
       (fabs (* im (* 0.5 (* re re))))
       (if (<= im 4.2e-7) (* im (- (cos re))) (- t_0 im))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -3.5e+91) {
		tmp = t_0;
	} else if (im <= -720.0) {
		tmp = fabs((im * (0.5 * (re * re))));
	} else if (im <= 4.2e-7) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0 - 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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-3.5d+91)) then
        tmp = t_0
    else if (im <= (-720.0d0)) then
        tmp = abs((im * (0.5d0 * (re * re))))
    else if (im <= 4.2d-7) then
        tmp = im * -cos(re)
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -3.5e+91) {
		tmp = t_0;
	} else if (im <= -720.0) {
		tmp = Math.abs((im * (0.5 * (re * re))));
	} else if (im <= 4.2e-7) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -3.5e+91:
		tmp = t_0
	elif im <= -720.0:
		tmp = math.fabs((im * (0.5 * (re * re))))
	elif im <= 4.2e-7:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -3.5e+91)
		tmp = t_0;
	elseif (im <= -720.0)
		tmp = abs(Float64(im * Float64(0.5 * Float64(re * re))));
	elseif (im <= 4.2e-7)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -3.5e+91)
		tmp = t_0;
	elseif (im <= -720.0)
		tmp = abs((im * (0.5 * (re * re))));
	elseif (im <= 4.2e-7)
		tmp = im * -cos(re);
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -3.5e+91], t$95$0, If[LessEqual[im, -720.0], N[Abs[N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 4.2e-7], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -720:\\
\;\;\;\;\left|im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.50000000000000001e91

    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-out79.1%

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

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

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

        \[\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*79.1%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 72.8%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*72.8%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified72.8%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 79.7%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative79.7%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified79.7%

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

    if -3.50000000000000001e91 < im < -720

    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-out65.5%

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

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

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

        \[\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*65.5%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 12.7%

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot im\right) \]
      2. associate-*r*11.8%

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

        \[\leadsto \left(\color{blue}{\left(-2 \cdot -0.25\right)} \cdot \left(re \cdot re\right)\right) \cdot im \]
      4. associate-*r*11.8%

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

        \[\leadsto \color{blue}{im \cdot \left(-2 \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. associate-*r*11.8%

        \[\leadsto im \cdot \left(-2 \cdot \color{blue}{\left(\left(-0.25 \cdot re\right) \cdot re\right)}\right) \]
      7. *-commutative11.8%

        \[\leadsto im \cdot \left(-2 \cdot \left(\color{blue}{\left(re \cdot -0.25\right)} \cdot re\right)\right) \]
      8. associate-*r*11.8%

        \[\leadsto im \cdot \color{blue}{\left(\left(-2 \cdot \left(re \cdot -0.25\right)\right) \cdot re\right)} \]
      9. *-commutative11.8%

        \[\leadsto im \cdot \left(\color{blue}{\left(\left(re \cdot -0.25\right) \cdot -2\right)} \cdot re\right) \]
      10. associate-*l*11.8%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot \left(-0.25 \cdot -2\right)\right)} \cdot re\right) \]
      11. metadata-eval11.8%

        \[\leadsto im \cdot \left(\left(re \cdot \color{blue}{0.5}\right) \cdot re\right) \]
    10. Simplified11.8%

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot 0.5\right) \cdot re\right)} \]
    11. Step-by-step derivation
      1. associate-*r*11.8%

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

        \[\leadsto \left(im \cdot \color{blue}{\left(0.5 \cdot re\right)}\right) \cdot re \]
      3. associate-*r*11.8%

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

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)} \]
      6. add-sqr-sqrt0.3%

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

        \[\leadsto \color{blue}{\sqrt{\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)}} \]
      8. associate-*r*32.0%

        \[\leadsto \sqrt{\color{blue}{\left(\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\right)} \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)} \]
      9. associate-*r*32.0%

        \[\leadsto \sqrt{\left(\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\right) \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\right)}} \]
      10. swap-sqr31.9%

        \[\leadsto \sqrt{\color{blue}{\left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)}} \]
      11. pow231.9%

        \[\leadsto \sqrt{\left(\color{blue}{{re}^{2}} \cdot \left(re \cdot re\right)\right) \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      12. pow231.9%

        \[\leadsto \sqrt{\left({re}^{2} \cdot \color{blue}{{re}^{2}}\right) \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      13. pow-prod-up31.9%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(2 + 2\right)}} \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      14. metadata-eval31.9%

        \[\leadsto \sqrt{{re}^{\color{blue}{4}} \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      15. swap-sqr31.9%

        \[\leadsto \sqrt{{re}^{4} \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(0.5 \cdot 0.5\right)\right)}} \]
      16. metadata-eval31.9%

        \[\leadsto \sqrt{{re}^{4} \cdot \left(\left(im \cdot im\right) \cdot \color{blue}{0.25}\right)} \]
    12. Applied egg-rr31.9%

      \[\leadsto \color{blue}{\sqrt{{re}^{4} \cdot \left(\left(im \cdot im\right) \cdot 0.25\right)}} \]
    13. Step-by-step derivation
      1. metadata-eval31.9%

        \[\leadsto \sqrt{{re}^{4} \cdot \left(\left(im \cdot im\right) \cdot \color{blue}{\left(0.5 \cdot 0.5\right)}\right)} \]
      2. swap-sqr31.9%

        \[\leadsto \sqrt{{re}^{4} \cdot \color{blue}{\left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)}} \]
      3. metadata-eval31.9%

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

        \[\leadsto \sqrt{\color{blue}{\left({re}^{3} \cdot re\right)} \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      5. unpow331.9%

        \[\leadsto \sqrt{\left(\color{blue}{\left(\left(re \cdot re\right) \cdot re\right)} \cdot re\right) \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      6. associate-*r*31.9%

        \[\leadsto \sqrt{\color{blue}{\left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)} \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)} \]
      7. associate-*l*32.0%

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot re\right) \cdot \left(\left(re \cdot re\right) \cdot \left(\left(im \cdot 0.5\right) \cdot \left(im \cdot 0.5\right)\right)\right)}} \]
      8. swap-sqr32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \color{blue}{\left(\left(re \cdot \left(im \cdot 0.5\right)\right) \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)}} \]
      9. associate-*l*32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\color{blue}{\left(\left(re \cdot im\right) \cdot 0.5\right)} \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)} \]
      10. *-commutative32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\left(\color{blue}{\left(im \cdot re\right)} \cdot 0.5\right) \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)} \]
      11. *-commutative32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\color{blue}{\left(0.5 \cdot \left(im \cdot re\right)\right)} \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right)} \]
      12. associate-*l*32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\left(0.5 \cdot \left(im \cdot re\right)\right) \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot 0.5\right)}\right)} \]
      13. *-commutative32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\left(0.5 \cdot \left(im \cdot re\right)\right) \cdot \left(\color{blue}{\left(im \cdot re\right)} \cdot 0.5\right)\right)} \]
      14. *-commutative32.0%

        \[\leadsto \sqrt{\left(re \cdot re\right) \cdot \left(\left(0.5 \cdot \left(im \cdot re\right)\right) \cdot \color{blue}{\left(0.5 \cdot \left(im \cdot re\right)\right)}\right)} \]
      15. swap-sqr32.0%

        \[\leadsto \sqrt{\color{blue}{\left(re \cdot \left(0.5 \cdot \left(im \cdot re\right)\right)\right) \cdot \left(re \cdot \left(0.5 \cdot \left(im \cdot re\right)\right)\right)}} \]
      16. rem-sqrt-square25.6%

        \[\leadsto \color{blue}{\left|re \cdot \left(0.5 \cdot \left(im \cdot re\right)\right)\right|} \]
      17. associate-*r*25.6%

        \[\leadsto \left|\color{blue}{\left(re \cdot 0.5\right) \cdot \left(im \cdot re\right)}\right| \]
      18. *-commutative25.6%

        \[\leadsto \left|\left(re \cdot 0.5\right) \cdot \color{blue}{\left(re \cdot im\right)}\right| \]
      19. associate-*r*25.6%

        \[\leadsto \left|\color{blue}{\left(\left(re \cdot 0.5\right) \cdot re\right) \cdot im}\right| \]
    14. Simplified25.6%

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

    if -720 < im < 4.2e-7

    1. Initial program 6.7%

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

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

      \[\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}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.8%

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

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

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

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

    if 4.2e-7 < im

    1. Initial program 99.6%

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

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

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

      \[\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-neg69.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification73.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.5 \cdot 10^{+91}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -720:\\ \;\;\;\;\left|im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\right|\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 12: 75.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -1.25 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\ \mathbf{elif}\;im \leq 36000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -1.25e+91)
     t_0
     (if (<= im -1.18e+44)
       (/
        (- 2.25 (* (* (* re re) (* re re)) 0.5625))
        (- -1.5 (* re (* re 0.75))))
       (if (<= im 36000000.0) (* im (- (cos re))) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -1.25e+91) {
		tmp = t_0;
	} else if (im <= -1.18e+44) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	} else if (im <= 36000000.0) {
		tmp = im * -cos(re);
	} 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)
    if (im <= (-1.25d+91)) then
        tmp = t_0
    else if (im <= (-1.18d+44)) then
        tmp = (2.25d0 - (((re * re) * (re * re)) * 0.5625d0)) / ((-1.5d0) - (re * (re * 0.75d0)))
    else if (im <= 36000000.0d0) then
        tmp = im * -cos(re)
    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;
	double tmp;
	if (im <= -1.25e+91) {
		tmp = t_0;
	} else if (im <= -1.18e+44) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	} else if (im <= 36000000.0) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -1.25e+91:
		tmp = t_0
	elif im <= -1.18e+44:
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)))
	elif im <= 36000000.0:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -1.25e+91)
		tmp = t_0;
	elseif (im <= -1.18e+44)
		tmp = Float64(Float64(2.25 - Float64(Float64(Float64(re * re) * Float64(re * re)) * 0.5625)) / Float64(-1.5 - Float64(re * Float64(re * 0.75))));
	elseif (im <= 36000000.0)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -1.25e+91)
		tmp = t_0;
	elseif (im <= -1.18e+44)
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - (re * (re * 0.75)));
	elseif (im <= 36000000.0)
		tmp = im * -cos(re);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -1.25e+91], t$95$0, If[LessEqual[im, -1.18e+44], N[(N[(2.25 - N[(N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] * 0.5625), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 36000000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\
\;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.2500000000000001e91 or 3.6e7 < 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 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-out74.5%

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

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

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

        \[\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*74.5%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 60.9%

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

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*60.9%

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

        \[\leadsto \left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Simplified60.9%

      \[\leadsto \color{blue}{\left(-0.3333333333333333 \cdot {im}^{3}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    11. Taylor expanded in re around 0 57.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    12. Step-by-step derivation
      1. *-commutative57.6%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    13. Simplified57.6%

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

    if -1.2500000000000001e91 < im < -1.17999999999999997e44

    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-out61.5%

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

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

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

        \[\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*61.5%

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

      \[\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-rr3.2%

      \[\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-in3.2%

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

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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. *-commutative38.8%

        \[\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. associate-*r*38.8%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\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)} \]
      8. associate-*l*38.8%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\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)} \]
      9. metadata-eval38.8%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\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)} \]
      10. *-commutative38.8%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\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)} \]
      11. associate-*r*38.8%

        \[\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*38.8%

        \[\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-eval38.8%

        \[\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-eval38.8%

        \[\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. *-commutative38.8%

        \[\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*38.8%

        \[\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*38.8%

        \[\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-eval38.8%

        \[\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-rr38.8%

      \[\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}} \]
    10. Step-by-step derivation
      1. swap-sqr38.8%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot \left(0.75 \cdot 0.75\right)}}{-1.5 - \left(re \cdot re\right) \cdot 0.75} \]
      2. metadata-eval38.8%

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

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - \color{blue}{re \cdot \left(re \cdot 0.75\right)}} \]
    11. Simplified38.8%

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

    if -1.17999999999999997e44 < im < 3.6e7

    1. Initial program 18.4%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified18.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 88.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.25 \cdot 10^{+91}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -1.18 \cdot 10^{+44}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\ \mathbf{elif}\;im \leq 36000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 13: 38.3% accurate, 7.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\ t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\ \mathbf{if}\;im \leq -5.6 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{+53}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+138}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+220}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* -0.25 (* re re))))
        (t_1 (/ (- (* im im) (* 4.0 (* t_0 t_0))) (- (- im) (* -2.0 t_0)))))
   (if (<= im -5.6e+25)
     t_1
     (if (<= im 4.7e+53)
       (- (* re (* re (* im 0.5))) im)
       (if (<= im 9.5e+138)
         (* (+ 0.5 (* re (* re -0.25))) 27.0)
         (if (<= im 8.2e+220) (- (* im (* re (* 0.5 re))) im) t_1))))))
double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -5.6e+25) {
		tmp = t_1;
	} else if (im <= 4.7e+53) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 9.5e+138) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 8.2e+220) {
		tmp = (im * (re * (0.5 * 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) :: tmp
    t_0 = im * ((-0.25d0) * (re * re))
    t_1 = ((im * im) - (4.0d0 * (t_0 * t_0))) / (-im - ((-2.0d0) * t_0))
    if (im <= (-5.6d+25)) then
        tmp = t_1
    else if (im <= 4.7d+53) then
        tmp = (re * (re * (im * 0.5d0))) - im
    else if (im <= 9.5d+138) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else if (im <= 8.2d+220) then
        tmp = (im * (re * (0.5d0 * re))) - im
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = im * (-0.25 * (re * re));
	double t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	double tmp;
	if (im <= -5.6e+25) {
		tmp = t_1;
	} else if (im <= 4.7e+53) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 9.5e+138) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else if (im <= 8.2e+220) {
		tmp = (im * (re * (0.5 * re))) - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (-0.25 * (re * re))
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0))
	tmp = 0
	if im <= -5.6e+25:
		tmp = t_1
	elif im <= 4.7e+53:
		tmp = (re * (re * (im * 0.5))) - im
	elif im <= 9.5e+138:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	elif im <= 8.2e+220:
		tmp = (im * (re * (0.5 * re))) - im
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(-0.25 * Float64(re * re)))
	t_1 = Float64(Float64(Float64(im * im) - Float64(4.0 * Float64(t_0 * t_0))) / Float64(Float64(-im) - Float64(-2.0 * t_0)))
	tmp = 0.0
	if (im <= -5.6e+25)
		tmp = t_1;
	elseif (im <= 4.7e+53)
		tmp = Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im);
	elseif (im <= 9.5e+138)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	elseif (im <= 8.2e+220)
		tmp = Float64(Float64(im * Float64(re * Float64(0.5 * re))) - im);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (-0.25 * (re * re));
	t_1 = ((im * im) - (4.0 * (t_0 * t_0))) / (-im - (-2.0 * t_0));
	tmp = 0.0;
	if (im <= -5.6e+25)
		tmp = t_1;
	elseif (im <= 4.7e+53)
		tmp = (re * (re * (im * 0.5))) - im;
	elseif (im <= 9.5e+138)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	elseif (im <= 8.2e+220)
		tmp = (im * (re * (0.5 * re))) - im;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(im * im), $MachinePrecision] - N[(4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-im) - N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6e+25], t$95$1, If[LessEqual[im, 4.7e+53], N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 9.5e+138], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], If[LessEqual[im, 8.2e+220], N[(N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
t_1 := \frac{im \cdot im - 4 \cdot \left(t_0 \cdot t_0\right)}{\left(-im\right) - -2 \cdot t_0}\\
\mathbf{if}\;im \leq -5.6 \cdot 10^{+25}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -5.6000000000000003e25 or 8.19999999999999962e220 < 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 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-out82.3%

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

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

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

        \[\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*82.3%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 18.0%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(-2 \cdot im\right) \cdot 0.5\right) \cdot \left(\left(-2 \cdot im\right) \cdot 0.5\right) - \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{\left(-2 \cdot im\right) \cdot 0.5 - \left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
    9. Applied egg-rr39.1%

      \[\leadsto \color{blue}{\frac{\left(im \cdot -1\right) \cdot \left(im \cdot -1\right) - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. swap-sqr39.1%

        \[\leadsto \frac{\color{blue}{\left(im \cdot im\right) \cdot \left(-1 \cdot -1\right)} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      2. metadata-eval39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot \color{blue}{1} - \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(-2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      3. swap-sqr39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{\left(-2 \cdot -2\right) \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      4. metadata-eval39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - \color{blue}{4} \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{im \cdot -1 - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      5. *-commutative39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{-1 \cdot im} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. mul-1-neg39.1%

        \[\leadsto \frac{\left(im \cdot im\right) \cdot 1 - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\color{blue}{\left(-im\right)} - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
    11. Simplified39.1%

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

    if -5.6000000000000003e25 < im < 4.69999999999999976e53

    1. Initial program 21.4%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified21.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 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(--0.5 \cdot im\right) - im \]
      10. associate-*l*52.1%

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

        \[\leadsto re \cdot \left(re \cdot \left(-\color{blue}{im \cdot -0.5}\right)\right) - im \]
      12. distribute-rgt-neg-in52.1%

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

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

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

    if 4.69999999999999976e53 < im < 9.49999999999999998e138

    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-out41.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow241.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*41.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified41.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-rr37.1%

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

    if 9.49999999999999998e138 < im < 8.19999999999999962e220

    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-out77.3%

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

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

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

        \[\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*77.3%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 77.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-1} \cdot im + -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \]
      7. *-commutative38.9%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot im\right)} \]
      8. associate-*l*38.9%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(-0.25 \cdot \left(\left(re \cdot re\right) \cdot im\right)\right)} \]
      9. associate-*r*38.9%

        \[\leadsto -1 \cdot im + \color{blue}{\left(-2 \cdot -0.25\right) \cdot \left(\left(re \cdot re\right) \cdot im\right)} \]
      10. metadata-eval38.9%

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

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

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

        \[\leadsto 0.5 \cdot \left({re}^{2} \cdot im\right) + \color{blue}{\left(-im\right)} \]
      14. unsub-neg38.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+25}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{+53}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+138}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+220}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{im \cdot im - 4 \cdot \left(\left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)\right)}{\left(-im\right) - -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)}\\ \end{array} \]

Alternative 14: 35.9% accurate, 13.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(re \cdot 0.75\right)\\ \mathbf{if}\;re \leq 6.6 \cdot 10^{+81}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 1.55 \cdot 10^{+154}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - t_0}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (* re 0.75))))
   (if (<= re 6.6e+81)
     (- (* im (* re (* 0.5 re))) im)
     (if (<= re 1.55e+154)
       (/ (- 2.25 (* (* (* re re) (* re re)) 0.5625)) (- -1.5 t_0))
       t_0))))
double code(double re, double im) {
	double t_0 = re * (re * 0.75);
	double tmp;
	if (re <= 6.6e+81) {
		tmp = (im * (re * (0.5 * re))) - im;
	} else if (re <= 1.55e+154) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - t_0);
	} 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 = re * (re * 0.75d0)
    if (re <= 6.6d+81) then
        tmp = (im * (re * (0.5d0 * re))) - im
    else if (re <= 1.55d+154) then
        tmp = (2.25d0 - (((re * re) * (re * re)) * 0.5625d0)) / ((-1.5d0) - t_0)
    else
        tmp = t_0
    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 <= 6.6e+81) {
		tmp = (im * (re * (0.5 * re))) - im;
	} else if (re <= 1.55e+154) {
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - t_0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (re * 0.75)
	tmp = 0
	if re <= 6.6e+81:
		tmp = (im * (re * (0.5 * re))) - im
	elif re <= 1.55e+154:
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - t_0)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(re * 0.75))
	tmp = 0.0
	if (re <= 6.6e+81)
		tmp = Float64(Float64(im * Float64(re * Float64(0.5 * re))) - im);
	elseif (re <= 1.55e+154)
		tmp = Float64(Float64(2.25 - Float64(Float64(Float64(re * re) * Float64(re * re)) * 0.5625)) / Float64(-1.5 - t_0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (re * 0.75);
	tmp = 0.0;
	if (re <= 6.6e+81)
		tmp = (im * (re * (0.5 * re))) - im;
	elseif (re <= 1.55e+154)
		tmp = (2.25 - (((re * re) * (re * re)) * 0.5625)) / (-1.5 - t_0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 6.6e+81], N[(N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 1.55e+154], N[(N[(2.25 - N[(N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] * 0.5625), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;re \leq 1.55 \cdot 10^{+154}:\\
\;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - t_0}\\

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


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

    1. Initial program 57.7%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified57.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 2.7%

      \[\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. *-commutative2.7%

        \[\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*2.7%

        \[\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-out45.7%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow245.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*45.7%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 61.2%

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot im\right)} \]
      8. associate-*l*39.9%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(-0.25 \cdot \left(\left(re \cdot re\right) \cdot im\right)\right)} \]
      9. associate-*r*39.9%

        \[\leadsto -1 \cdot im + \color{blue}{\left(-2 \cdot -0.25\right) \cdot \left(\left(re \cdot re\right) \cdot im\right)} \]
      10. metadata-eval39.9%

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

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

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

        \[\leadsto 0.5 \cdot \left({re}^{2} \cdot im\right) + \color{blue}{\left(-im\right)} \]
      14. unsub-neg39.9%

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

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

    if 6.6e81 < re < 1.5500000000000001e154

    1. Initial program 49.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified49.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 2.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. *-commutative2.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*2.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-out14.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow214.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*14.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified14.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-rr4.1%

      \[\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-in4.1%

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

        \[\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-eval36.3%

        \[\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-eval36.3%

        \[\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-eval36.3%

        \[\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. *-commutative36.3%

        \[\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. associate-*r*36.3%

        \[\leadsto \frac{2.25 - \left(\color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\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)} \]
      8. associate-*l*36.3%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot -3\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)} \]
      9. metadata-eval36.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \color{blue}{0.75}\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)} \]
      10. *-commutative36.3%

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot 0.75\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)} \]
      11. associate-*r*36.3%

        \[\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*36.3%

        \[\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-eval36.3%

        \[\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-eval36.3%

        \[\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. *-commutative36.3%

        \[\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*36.3%

        \[\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*36.3%

        \[\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-eval36.3%

        \[\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-rr36.3%

      \[\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}} \]
    10. Step-by-step derivation
      1. swap-sqr36.3%

        \[\leadsto \frac{2.25 - \color{blue}{\left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot \left(0.75 \cdot 0.75\right)}}{-1.5 - \left(re \cdot re\right) \cdot 0.75} \]
      2. metadata-eval36.3%

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

        \[\leadsto \frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - \color{blue}{re \cdot \left(re \cdot 0.75\right)}} \]
    11. Simplified36.3%

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

    if 1.5500000000000001e154 < re

    1. Initial program 62.5%

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

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

      \[\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-out28.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow228.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*28.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified28.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-rr28.8%

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

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

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative28.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 6.6 \cdot 10^{+81}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 1.55 \cdot 10^{+154}:\\ \;\;\;\;\frac{2.25 - \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) \cdot 0.5625}{-1.5 - re \cdot \left(re \cdot 0.75\right)}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

Alternative 15: 36.6% accurate, 20.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{if}\;im \leq -126000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+52}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* re (* 0.5 re)))))
   (if (<= im -126000000.0)
     t_0
     (if (<= im 9.8e+52)
       (- im)
       (if (<= im 4.3e+139) (* (+ 0.5 (* re (* re -0.25))) 27.0) t_0)))))
double code(double re, double im) {
	double t_0 = im * (re * (0.5 * re));
	double tmp;
	if (im <= -126000000.0) {
		tmp = t_0;
	} else if (im <= 9.8e+52) {
		tmp = -im;
	} else if (im <= 4.3e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} 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 * (re * (0.5d0 * re))
    if (im <= (-126000000.0d0)) then
        tmp = t_0
    else if (im <= 9.8d+52) then
        tmp = -im
    else if (im <= 4.3d+139) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = im * (re * (0.5 * re));
	double tmp;
	if (im <= -126000000.0) {
		tmp = t_0;
	} else if (im <= 9.8e+52) {
		tmp = -im;
	} else if (im <= 4.3e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (re * (0.5 * re))
	tmp = 0
	if im <= -126000000.0:
		tmp = t_0
	elif im <= 9.8e+52:
		tmp = -im
	elif im <= 4.3e+139:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(re * Float64(0.5 * re)))
	tmp = 0.0
	if (im <= -126000000.0)
		tmp = t_0;
	elseif (im <= 9.8e+52)
		tmp = Float64(-im);
	elseif (im <= 4.3e+139)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (re * (0.5 * re));
	tmp = 0.0;
	if (im <= -126000000.0)
		tmp = t_0;
	elseif (im <= 9.8e+52)
		tmp = -im;
	elseif (im <= 4.3e+139)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -126000000.0], t$95$0, If[LessEqual[im, 9.8e+52], (-im), If[LessEqual[im, 4.3e+139], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\
\mathbf{if}\;im \leq -126000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 9.8 \cdot 10^{+52}:\\
\;\;\;\;-im\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.26e8 or 4.2999999999999998e139 < 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 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-out79.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow279.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*79.8%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 23.7%

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

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

        \[\leadsto 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot im\right) \]
      2. associate-*r*21.3%

        \[\leadsto \color{blue}{\left(0.5 \cdot \left(re \cdot re\right)\right) \cdot im} \]
      3. metadata-eval21.3%

        \[\leadsto \left(\color{blue}{\left(-2 \cdot -0.25\right)} \cdot \left(re \cdot re\right)\right) \cdot im \]
      4. associate-*r*21.3%

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

        \[\leadsto \color{blue}{im \cdot \left(-2 \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. associate-*r*21.3%

        \[\leadsto im \cdot \left(-2 \cdot \color{blue}{\left(\left(-0.25 \cdot re\right) \cdot re\right)}\right) \]
      7. *-commutative21.3%

        \[\leadsto im \cdot \left(-2 \cdot \left(\color{blue}{\left(re \cdot -0.25\right)} \cdot re\right)\right) \]
      8. associate-*r*21.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-2 \cdot \left(re \cdot -0.25\right)\right) \cdot re\right)} \]
      9. *-commutative21.3%

        \[\leadsto im \cdot \left(\color{blue}{\left(\left(re \cdot -0.25\right) \cdot -2\right)} \cdot re\right) \]
      10. associate-*l*21.3%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot \left(-0.25 \cdot -2\right)\right)} \cdot re\right) \]
      11. metadata-eval21.3%

        \[\leadsto im \cdot \left(\left(re \cdot \color{blue}{0.5}\right) \cdot re\right) \]
    10. Simplified21.3%

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

    if -1.26e8 < im < 9.79999999999999993e52

    1. Initial program 16.6%

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

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

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

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

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

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

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

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

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

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

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

    if 9.79999999999999993e52 < im < 4.2999999999999998e139

    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-out41.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow241.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*41.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified41.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-rr37.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -126000000:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+52}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \end{array} \]

Alternative 16: 35.8% accurate, 23.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.4 \cdot 10^{+238}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\

\mathbf{elif}\;re \leq 1.1 \cdot 10^{+279}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

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


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

    1. Initial program 56.9%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.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 2.5%

      \[\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. *-commutative2.5%

        \[\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*2.5%

        \[\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-out42.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow242.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*42.8%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 56.2%

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

      \[\leadsto \color{blue}{-2 \cdot \left(im \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-in37.7%

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

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

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

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

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

        \[\leadsto \color{blue}{-1} \cdot im + -2 \cdot \left(im \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right) \]
      7. *-commutative37.7%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot im\right)} \]
      8. associate-*l*37.7%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(-0.25 \cdot \left(\left(re \cdot re\right) \cdot im\right)\right)} \]
      9. associate-*r*37.7%

        \[\leadsto -1 \cdot im + \color{blue}{\left(-2 \cdot -0.25\right) \cdot \left(\left(re \cdot re\right) \cdot im\right)} \]
      10. metadata-eval37.7%

        \[\leadsto -1 \cdot im + \color{blue}{0.5} \cdot \left(\left(re \cdot re\right) \cdot im\right) \]
      11. unpow237.7%

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

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

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

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

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

    if 1.39999999999999995e238 < re < 1.1e279

    1. Initial program 90.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified90.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 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-out28.7%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow228.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*28.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified28.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-rr57.6%

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

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

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative57.6%

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

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

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

    if 1.1e279 < re

    1. Initial program 37.6%

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

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

      \[\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-out0.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow20.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*0.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified0.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-rr34.1%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification38.2%

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

Alternative 17: 35.7% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{+54}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 1.86 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 9e+54)
   (- (* re (* re (* im 0.5))) im)
   (if (<= im 1.86e+139)
     (* (+ 0.5 (* re (* re -0.25))) 27.0)
     (- (* im (* re (* 0.5 re))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= 9e+54) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 1.86e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = (im * (re * (0.5 * 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 <= 9d+54) then
        tmp = (re * (re * (im * 0.5d0))) - im
    else if (im <= 1.86d+139) then
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    else
        tmp = (im * (re * (0.5d0 * re))) - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 9e+54) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (im <= 1.86e+139) {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	} else {
		tmp = (im * (re * (0.5 * re))) - im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 9e+54:
		tmp = (re * (re * (im * 0.5))) - im
	elif im <= 1.86e+139:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	else:
		tmp = (im * (re * (0.5 * re))) - im
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 9e+54)
		tmp = Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im);
	elseif (im <= 1.86e+139)
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	else
		tmp = Float64(Float64(im * Float64(re * Float64(0.5 * re))) - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 9e+54)
		tmp = (re * (re * (im * 0.5))) - im;
	elseif (im <= 1.86e+139)
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	else
		tmp = (im * (re * (0.5 * re))) - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 9e+54], N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.86e+139], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision], N[(N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 9 \cdot 10^{+54}:\\
\;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\

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

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


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

    1. Initial program 45.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(im \cdot 0.5\right)} - im \]
      6. metadata-eval39.5%

        \[\leadsto {re}^{2} \cdot \left(im \cdot \color{blue}{\left(--0.5\right)}\right) - im \]
      7. distribute-rgt-neg-in39.5%

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

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

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(--0.5 \cdot im\right) - im \]
      10. associate-*l*39.6%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(--0.5 \cdot im\right)\right)} - im \]
      11. *-commutative39.6%

        \[\leadsto re \cdot \left(re \cdot \left(-\color{blue}{im \cdot -0.5}\right)\right) - im \]
      12. distribute-rgt-neg-in39.6%

        \[\leadsto re \cdot \left(re \cdot \color{blue}{\left(im \cdot \left(--0.5\right)\right)}\right) - im \]
      13. metadata-eval39.6%

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

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

    if 8.99999999999999968e54 < im < 1.8600000000000001e139

    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-out41.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow241.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*41.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified41.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-rr37.1%

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

    if 1.8600000000000001e139 < 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 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-out87.2%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow287.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*87.2%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 87.2%

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

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

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

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

        \[\leadsto -2 \cdot \left(0.5 \cdot im + im \cdot \left(-0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      4. distribute-lft-in39.5%

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

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

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

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot im\right)} \]
      8. associate-*l*39.5%

        \[\leadsto -1 \cdot im + -2 \cdot \color{blue}{\left(-0.25 \cdot \left(\left(re \cdot re\right) \cdot im\right)\right)} \]
      9. associate-*r*39.5%

        \[\leadsto -1 \cdot im + \color{blue}{\left(-2 \cdot -0.25\right) \cdot \left(\left(re \cdot re\right) \cdot im\right)} \]
      10. metadata-eval39.5%

        \[\leadsto -1 \cdot im + \color{blue}{0.5} \cdot \left(\left(re \cdot re\right) \cdot im\right) \]
      11. unpow239.5%

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

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

        \[\leadsto 0.5 \cdot \left({re}^{2} \cdot im\right) + \color{blue}{\left(-im\right)} \]
      14. unsub-neg39.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{+54}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 1.86 \cdot 10^{+139}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right) - im\\ \end{array} \]

Alternative 18: 36.8% accurate, 27.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -54000000 \lor \neg \left(im \leq 4.6 \cdot 10^{+41}\right):\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -54000000.0) (not (<= im 4.6e+41)))
   (* im (* re (* 0.5 re)))
   (- im)))
double code(double re, double im) {
	double tmp;
	if ((im <= -54000000.0) || !(im <= 4.6e+41)) {
		tmp = im * (re * (0.5 * re));
	} else {
		tmp = -im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-54000000.0d0)) .or. (.not. (im <= 4.6d+41))) then
        tmp = im * (re * (0.5d0 * re))
    else
        tmp = -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -54000000.0) || !(im <= 4.6e+41)) {
		tmp = im * (re * (0.5 * re));
	} else {
		tmp = -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -54000000.0) or not (im <= 4.6e+41):
		tmp = im * (re * (0.5 * re))
	else:
		tmp = -im
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -54000000.0) || !(im <= 4.6e+41))
		tmp = Float64(im * Float64(re * Float64(0.5 * re)));
	else
		tmp = Float64(-im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -54000000.0) || ~((im <= 4.6e+41)))
		tmp = im * (re * (0.5 * re));
	else
		tmp = -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -54000000.0], N[Not[LessEqual[im, 4.6e+41]], $MachinePrecision]], N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -54000000 \lor \neg \left(im \leq 4.6 \cdot 10^{+41}\right):\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.4e7 or 4.5999999999999997e41 < 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 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-out75.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow275.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*75.0%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Taylor expanded in im around 0 21.2%

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

      \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    9. Step-by-step derivation
      1. unpow219.0%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot im\right) \]
      2. associate-*r*19.0%

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

        \[\leadsto \left(\color{blue}{\left(-2 \cdot -0.25\right)} \cdot \left(re \cdot re\right)\right) \cdot im \]
      4. associate-*r*19.0%

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

        \[\leadsto \color{blue}{im \cdot \left(-2 \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\right)} \]
      6. associate-*r*19.0%

        \[\leadsto im \cdot \left(-2 \cdot \color{blue}{\left(\left(-0.25 \cdot re\right) \cdot re\right)}\right) \]
      7. *-commutative19.0%

        \[\leadsto im \cdot \left(-2 \cdot \left(\color{blue}{\left(re \cdot -0.25\right)} \cdot re\right)\right) \]
      8. associate-*r*19.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-2 \cdot \left(re \cdot -0.25\right)\right) \cdot re\right)} \]
      9. *-commutative19.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(\left(re \cdot -0.25\right) \cdot -2\right)} \cdot re\right) \]
      10. associate-*l*19.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot \left(-0.25 \cdot -2\right)\right)} \cdot re\right) \]
      11. metadata-eval19.0%

        \[\leadsto im \cdot \left(\left(re \cdot \color{blue}{0.5}\right) \cdot re\right) \]
    10. Simplified19.0%

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

    if -5.4e7 < im < 4.5999999999999997e41

    1. Initial program 15.2%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.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 91.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -54000000 \lor \neg \left(im \leq 4.6 \cdot 10^{+41}\right):\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 19: 31.7% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 4.8 \cdot 10^{+165}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 4.8e+165) (- im) (* re (* re 0.75))))
double code(double re, double im) {
	double tmp;
	if (re <= 4.8e+165) {
		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 <= 4.8d+165) 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 <= 4.8e+165) {
		tmp = -im;
	} else {
		tmp = re * (re * 0.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 4.8e+165:
		tmp = -im
	else:
		tmp = re * (re * 0.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 4.8e+165)
		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 <= 4.8e+165)
		tmp = -im;
	else
		tmp = re * (re * 0.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 4.8e+165], (-im), N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 4.8 \cdot 10^{+165}:\\
\;\;\;\;-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 < 4.80000000000000001e165

    1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

    if 4.80000000000000001e165 < re

    1. Initial program 66.0%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified66.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.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-out32.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow232.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*32.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified32.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-rr32.6%

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

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

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative32.6%

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

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

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

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

Alternative 20: 29.8% 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 57.6%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

Alternative 21: 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 57.6%

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

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
  4. Taylor expanded in re around 0 2.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. *-commutative2.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*2.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-out41.9%

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

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

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
    6. unpow241.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*41.9%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
  6. Simplified41.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-rr9.4%

    \[\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.6%

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

    \[\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 2023257 
(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))))