math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.5s
Alternatives: 15
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

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

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in re around inf 100.0%

    \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
  5. Final simplification100.0%

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

Alternative 2: 100.0% accurate, 1.0× speedup?

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

\\
\left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
    3. cancel-sign-sub100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
    4. distribute-lft-neg-out100.0%

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

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
    6. distribute-rgt-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
    7. neg-mul-1100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    8. associate-*r*100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    9. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
    11. neg-sub0100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
    12. *-commutative100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
    13. neg-mul-1100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
    14. remove-double-neg100.0%

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

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

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

Alternative 3: 74.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right) \end{array} \]
(FPCore (re im) :precision binary64 (* (sin re) (fma 0.5 (exp im) 0.5)))
double code(double re, double im) {
	return sin(re) * fma(0.5, exp(im), 0.5);
}
function code(re, im)
	return Float64(sin(re) * fma(0.5, exp(im), 0.5))
end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

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

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

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

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 75.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  5. Final simplification75.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right) \]

Alternative 4: 70.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot {im}^{2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (+ (* 0.5 (exp im)) 4.0))))
   (if (<= im 125.0)
     (sin re)
     (if (<= im 1.55e+67)
       t_0
       (if (<= im 6.3e+105)
         (+ (* -0.75 (pow re 3.0)) (* re 4.5))
         (if (<= im 1.32e+154) t_0 (* (* (sin re) 0.5) (pow im 2.0))))))))
double code(double re, double im) {
	double t_0 = re * ((0.5 * exp(im)) + 4.0);
	double tmp;
	if (im <= 125.0) {
		tmp = sin(re);
	} else if (im <= 1.55e+67) {
		tmp = t_0;
	} else if (im <= 6.3e+105) {
		tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
	} else if (im <= 1.32e+154) {
		tmp = t_0;
	} else {
		tmp = (sin(re) * 0.5) * pow(im, 2.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 * ((0.5d0 * exp(im)) + 4.0d0)
    if (im <= 125.0d0) then
        tmp = sin(re)
    else if (im <= 1.55d+67) then
        tmp = t_0
    else if (im <= 6.3d+105) then
        tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
    else if (im <= 1.32d+154) then
        tmp = t_0
    else
        tmp = (sin(re) * 0.5d0) * (im ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * ((0.5 * Math.exp(im)) + 4.0);
	double tmp;
	if (im <= 125.0) {
		tmp = Math.sin(re);
	} else if (im <= 1.55e+67) {
		tmp = t_0;
	} else if (im <= 6.3e+105) {
		tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
	} else if (im <= 1.32e+154) {
		tmp = t_0;
	} else {
		tmp = (Math.sin(re) * 0.5) * Math.pow(im, 2.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = re * ((0.5 * math.exp(im)) + 4.0)
	tmp = 0
	if im <= 125.0:
		tmp = math.sin(re)
	elif im <= 1.55e+67:
		tmp = t_0
	elif im <= 6.3e+105:
		tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5)
	elif im <= 1.32e+154:
		tmp = t_0
	else:
		tmp = (math.sin(re) * 0.5) * math.pow(im, 2.0)
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0))
	tmp = 0.0
	if (im <= 125.0)
		tmp = sin(re);
	elseif (im <= 1.55e+67)
		tmp = t_0;
	elseif (im <= 6.3e+105)
		tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5));
	elseif (im <= 1.32e+154)
		tmp = t_0;
	else
		tmp = Float64(Float64(sin(re) * 0.5) * (im ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * ((0.5 * exp(im)) + 4.0);
	tmp = 0.0;
	if (im <= 125.0)
		tmp = sin(re);
	elseif (im <= 1.55e+67)
		tmp = t_0;
	elseif (im <= 6.3e+105)
		tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5);
	elseif (im <= 1.32e+154)
		tmp = t_0;
	else
		tmp = (sin(re) * 0.5) * (im ^ 2.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+67], t$95$0, If[LessEqual[im, 6.3e+105], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.32e+154], t$95$0, N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\

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

\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot {im}^{2}\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im < 1.31999999999999998e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around 0 94.7%

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

    if 1.54999999999999998e67 < im < 6.29999999999999953e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 2.9%

      \[\leadsto \color{blue}{4.5 \cdot \sin re} \]
    7. Step-by-step derivation
      1. *-commutative2.9%

        \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    8. Simplified2.9%

      \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    9. Taylor expanded in re around 0 67.0%

      \[\leadsto \color{blue}{-0.75 \cdot {re}^{3} + 4.5 \cdot re} \]

    if 1.31999999999999998e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

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

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    8. Step-by-step derivation
      1. associate-*r*100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot {im}^{2}\\ \end{array} \]

Alternative 5: 75.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.6:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1.6) (sin re) (* (sin re) (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.6) {
		tmp = sin(re);
	} else {
		tmp = sin(re) * ((0.5 * exp(im)) + 4.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 1.6d0) then
        tmp = sin(re)
    else
        tmp = sin(re) * ((0.5d0 * exp(im)) + 4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.6) {
		tmp = Math.sin(re);
	} else {
		tmp = Math.sin(re) * ((0.5 * Math.exp(im)) + 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.6:
		tmp = math.sin(re)
	else:
		tmp = math.sin(re) * ((0.5 * math.exp(im)) + 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.6)
		tmp = sin(re);
	else
		tmp = Float64(sin(re) * Float64(Float64(0.5 * exp(im)) + 4.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.6)
		tmp = sin(re);
	else
		tmp = sin(re) * ((0.5 * exp(im)) + 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.6], N[Sin[re], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.6:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 69.0%

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

    if 1.6000000000000001 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.6:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \]

Alternative 6: 87.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.7:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.7)
   (* (* (sin re) 0.5) (fma im im 2.0))
   (* (sin re) (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.7) {
		tmp = (sin(re) * 0.5) * fma(im, im, 2.0);
	} else {
		tmp = sin(re) * ((0.5 * exp(im)) + 4.0);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 2.7)
		tmp = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0));
	else
		tmp = Float64(sin(re) * Float64(Float64(0.5 * exp(im)) + 4.0));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 2.7], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

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

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow283.6%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def83.6%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Simplified83.6%

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

    if 2.7000000000000002 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.7:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \]

Alternative 7: 70.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (+ (* 0.5 (exp im)) 4.0))))
   (if (<= im 125.0)
     (sin re)
     (if (<= im 1.55e+67)
       t_0
       (if (<= im 6.3e+105)
         (+ (* -0.75 (pow re 3.0)) (* re 4.5))
         (if (<= im 3e+154)
           t_0
           (* (sin re) (+ 4.5 (* im (+ 0.5 (* im 0.25)))))))))))
double code(double re, double im) {
	double t_0 = re * ((0.5 * exp(im)) + 4.0);
	double tmp;
	if (im <= 125.0) {
		tmp = sin(re);
	} else if (im <= 1.55e+67) {
		tmp = t_0;
	} else if (im <= 6.3e+105) {
		tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
	} else if (im <= 3e+154) {
		tmp = t_0;
	} else {
		tmp = sin(re) * (4.5 + (im * (0.5 + (im * 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 = re * ((0.5d0 * exp(im)) + 4.0d0)
    if (im <= 125.0d0) then
        tmp = sin(re)
    else if (im <= 1.55d+67) then
        tmp = t_0
    else if (im <= 6.3d+105) then
        tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
    else if (im <= 3d+154) then
        tmp = t_0
    else
        tmp = sin(re) * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * ((0.5 * Math.exp(im)) + 4.0);
	double tmp;
	if (im <= 125.0) {
		tmp = Math.sin(re);
	} else if (im <= 1.55e+67) {
		tmp = t_0;
	} else if (im <= 6.3e+105) {
		tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
	} else if (im <= 3e+154) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * (4.5 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
def code(re, im):
	t_0 = re * ((0.5 * math.exp(im)) + 4.0)
	tmp = 0
	if im <= 125.0:
		tmp = math.sin(re)
	elif im <= 1.55e+67:
		tmp = t_0
	elif im <= 6.3e+105:
		tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5)
	elif im <= 3e+154:
		tmp = t_0
	else:
		tmp = math.sin(re) * (4.5 + (im * (0.5 + (im * 0.25))))
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0))
	tmp = 0.0
	if (im <= 125.0)
		tmp = sin(re);
	elseif (im <= 1.55e+67)
		tmp = t_0;
	elseif (im <= 6.3e+105)
		tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5));
	elseif (im <= 3e+154)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * ((0.5 * exp(im)) + 4.0);
	tmp = 0.0;
	if (im <= 125.0)
		tmp = sin(re);
	elseif (im <= 1.55e+67)
		tmp = t_0;
	elseif (im <= 6.3e+105)
		tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5);
	elseif (im <= 3e+154)
		tmp = t_0;
	else
		tmp = sin(re) * (4.5 + (im * (0.5 + (im * 0.25))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+67], t$95$0, If[LessEqual[im, 6.3e+105], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3e+154], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\

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

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im < 3.00000000000000026e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around 0 94.7%

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

    if 1.54999999999999998e67 < im < 6.29999999999999953e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 2.9%

      \[\leadsto \color{blue}{4.5 \cdot \sin re} \]
    7. Step-by-step derivation
      1. *-commutative2.9%

        \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    8. Simplified2.9%

      \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    9. Taylor expanded in re around 0 67.0%

      \[\leadsto \color{blue}{-0.75 \cdot {re}^{3} + 4.5 \cdot re} \]

    if 3.00000000000000026e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{0.25 \cdot \left({im}^{2} \cdot \sin re\right) + \left(0.5 \cdot \left(im \cdot \sin re\right) + 4.5 \cdot \sin re\right)} \]
    7. Step-by-step derivation
      1. associate-+r+100.0%

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

        \[\leadsto \color{blue}{4.5 \cdot \sin re + \left(0.25 \cdot \left({im}^{2} \cdot \sin re\right) + 0.5 \cdot \left(im \cdot \sin re\right)\right)} \]
      3. *-commutative100.0%

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

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

        \[\leadsto \sin re \cdot 4.5 + \left(\left(0.25 \cdot {im}^{2}\right) \cdot \sin re + \color{blue}{\left(0.5 \cdot im\right) \cdot \sin re}\right) \]
      6. distribute-rgt-out100.0%

        \[\leadsto \sin re \cdot 4.5 + \color{blue}{\sin re \cdot \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)} \]
      7. distribute-lft-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \]
      8. unpow2100.0%

        \[\leadsto \sin re \cdot \left(4.5 + \left(0.25 \cdot \color{blue}{\left(im \cdot im\right)} + 0.5 \cdot im\right)\right) \]
      9. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(4.5 + \left(\color{blue}{\left(0.25 \cdot im\right) \cdot im} + 0.5 \cdot im\right)\right) \]
      10. distribute-rgt-out100.0%

        \[\leadsto \sin re \cdot \left(4.5 + \color{blue}{im \cdot \left(0.25 \cdot im + 0.5\right)}\right) \]
    8. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 8: 67.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67} \lor \neg \left(im \leq 6.3 \cdot 10^{+105}\right):\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{else}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 125.0)
   (sin re)
   (if (or (<= im 1.55e+67) (not (<= im 6.3e+105)))
     (* re (+ (* 0.5 (exp im)) 4.0))
     (+ (* -0.75 (pow re 3.0)) (* re 4.5)))))
double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = sin(re);
	} else if ((im <= 1.55e+67) || !(im <= 6.3e+105)) {
		tmp = re * ((0.5 * exp(im)) + 4.0);
	} else {
		tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 125.0d0) then
        tmp = sin(re)
    else if ((im <= 1.55d+67) .or. (.not. (im <= 6.3d+105))) then
        tmp = re * ((0.5d0 * exp(im)) + 4.0d0)
    else
        tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = Math.sin(re);
	} else if ((im <= 1.55e+67) || !(im <= 6.3e+105)) {
		tmp = re * ((0.5 * Math.exp(im)) + 4.0);
	} else {
		tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 125.0:
		tmp = math.sin(re)
	elif (im <= 1.55e+67) or not (im <= 6.3e+105):
		tmp = re * ((0.5 * math.exp(im)) + 4.0)
	else:
		tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 125.0)
		tmp = sin(re);
	elseif ((im <= 1.55e+67) || !(im <= 6.3e+105))
		tmp = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0));
	else
		tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 125.0)
		tmp = sin(re);
	elseif ((im <= 1.55e+67) || ~((im <= 6.3e+105)))
		tmp = re * ((0.5 * exp(im)) + 4.0);
	else
		tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 1.55e+67], N[Not[LessEqual[im, 6.3e+105]], $MachinePrecision]], N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67} \lor \neg \left(im \leq 6.3 \cdot 10^{+105}\right):\\
\;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\

\mathbf{else}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around 0 82.4%

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

    if 1.54999999999999998e67 < im < 6.29999999999999953e105

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 2.9%

      \[\leadsto \color{blue}{4.5 \cdot \sin re} \]
    7. Step-by-step derivation
      1. *-commutative2.9%

        \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    8. Simplified2.9%

      \[\leadsto \color{blue}{\sin re \cdot 4.5} \]
    9. Taylor expanded in re around 0 67.0%

      \[\leadsto \color{blue}{-0.75 \cdot {re}^{3} + 4.5 \cdot re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+67} \lor \neg \left(im \leq 6.3 \cdot 10^{+105}\right):\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \mathbf{else}:\\ \;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\ \end{array} \]

Alternative 9: 64.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 800:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+138}:\\ \;\;\;\;\frac{1}{{re}^{3}}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 800.0)
   (sin re)
   (if (<= im 8.2e+138) (/ 1.0 (pow re 3.0)) (* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 800.0) {
		tmp = sin(re);
	} else if (im <= 8.2e+138) {
		tmp = 1.0 / pow(re, 3.0);
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 800.0d0) then
        tmp = sin(re)
    else if (im <= 8.2d+138) then
        tmp = 1.0d0 / (re ** 3.0d0)
    else
        tmp = re * (0.5d0 * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 800.0) {
		tmp = Math.sin(re);
	} else if (im <= 8.2e+138) {
		tmp = 1.0 / Math.pow(re, 3.0);
	} else {
		tmp = re * (0.5 * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 800.0:
		tmp = math.sin(re)
	elif im <= 8.2e+138:
		tmp = 1.0 / math.pow(re, 3.0)
	else:
		tmp = re * (0.5 * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 800.0)
		tmp = sin(re);
	elseif (im <= 8.2e+138)
		tmp = Float64(1.0 / (re ^ 3.0));
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 800.0)
		tmp = sin(re);
	elseif (im <= 8.2e+138)
		tmp = 1.0 / (re ^ 3.0);
	else
		tmp = re * (0.5 * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.2e+138], N[(1.0 / N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 800:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 8.2 \cdot 10^{+138}:\\
\;\;\;\;\frac{1}{{re}^{3}}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 800 < im < 8.19999999999999961e138

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr39.5%

      \[\leadsto \color{blue}{{\sin re}^{-3}} \]
    6. Taylor expanded in re around 0 38.7%

      \[\leadsto \color{blue}{\frac{1}{{re}^{3}}} \]

    if 8.19999999999999961e138 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

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

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def97.2%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Simplified97.2%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Taylor expanded in re around 0 72.9%

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 \cdot re\right) \]
      5. fma-def72.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re\right) \]
    9. Simplified72.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)} \]
    10. Taylor expanded in im around inf 72.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 800:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+138}:\\ \;\;\;\;\frac{1}{{re}^{3}}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]

Alternative 10: 68.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 125.0) (sin re) (* re (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = sin(re);
	} else {
		tmp = re * ((0.5 * exp(im)) + 4.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 125.0d0) then
        tmp = sin(re)
    else
        tmp = re * ((0.5d0 * exp(im)) + 4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = Math.sin(re);
	} else {
		tmp = re * ((0.5 * Math.exp(im)) + 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 125.0:
		tmp = math.sin(re)
	else:
		tmp = re * ((0.5 * math.exp(im)) + 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 125.0)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 125.0)
		tmp = sin(re);
	else
		tmp = re * ((0.5 * exp(im)) + 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 125 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around 0 77.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\ \end{array} \]

Alternative 11: 64.1% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 500:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+138}:\\ \;\;\;\;\frac{1}{{re}^{3}}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 500.0)
   (sin re)
   (if (<= im 2.1e+138)
     (/ 1.0 (pow re 3.0))
     (* re (+ 4.5 (* im (+ 0.5 (* im 0.25))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 500.0) {
		tmp = sin(re);
	} else if (im <= 2.1e+138) {
		tmp = 1.0 / pow(re, 3.0);
	} else {
		tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 500.0d0) then
        tmp = sin(re)
    else if (im <= 2.1d+138) then
        tmp = 1.0d0 / (re ** 3.0d0)
    else
        tmp = re * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 500.0) {
		tmp = Math.sin(re);
	} else if (im <= 2.1e+138) {
		tmp = 1.0 / Math.pow(re, 3.0);
	} else {
		tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 500.0:
		tmp = math.sin(re)
	elif im <= 2.1e+138:
		tmp = 1.0 / math.pow(re, 3.0)
	else:
		tmp = re * (4.5 + (im * (0.5 + (im * 0.25))))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 500.0)
		tmp = sin(re);
	elseif (im <= 2.1e+138)
		tmp = Float64(1.0 / (re ^ 3.0));
	else
		tmp = Float64(re * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 500.0)
		tmp = sin(re);
	elseif (im <= 2.1e+138)
		tmp = 1.0 / (re ^ 3.0);
	else
		tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 500.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.1e+138], N[(1.0 / N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 500:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 2.1 \cdot 10^{+138}:\\
\;\;\;\;\frac{1}{{re}^{3}}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.7%

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

    if 500 < im < 2.10000000000000007e138

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr39.5%

      \[\leadsto \color{blue}{{\sin re}^{-3}} \]
    6. Taylor expanded in re around 0 38.7%

      \[\leadsto \color{blue}{\frac{1}{{re}^{3}}} \]

    if 2.10000000000000007e138 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 97.2%

      \[\leadsto \color{blue}{0.25 \cdot \left({im}^{2} \cdot \sin re\right) + \left(0.5 \cdot \left(im \cdot \sin re\right) + 4.5 \cdot \sin re\right)} \]
    7. Step-by-step derivation
      1. associate-+r+97.2%

        \[\leadsto \color{blue}{\left(0.25 \cdot \left({im}^{2} \cdot \sin re\right) + 0.5 \cdot \left(im \cdot \sin re\right)\right) + 4.5 \cdot \sin re} \]
      2. +-commutative97.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \]
      8. unpow297.2%

        \[\leadsto \sin re \cdot \left(4.5 + \left(0.25 \cdot \color{blue}{\left(im \cdot im\right)} + 0.5 \cdot im\right)\right) \]
      9. associate-*r*97.2%

        \[\leadsto \sin re \cdot \left(4.5 + \left(\color{blue}{\left(0.25 \cdot im\right) \cdot im} + 0.5 \cdot im\right)\right) \]
      10. distribute-rgt-out97.2%

        \[\leadsto \sin re \cdot \left(4.5 + \color{blue}{im \cdot \left(0.25 \cdot im + 0.5\right)}\right) \]
    8. Simplified97.2%

      \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + im \cdot \left(0.25 \cdot im + 0.5\right)\right)} \]
    9. Taylor expanded in re around 0 72.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 500:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+138}:\\ \;\;\;\;\frac{1}{{re}^{3}}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 12: 61.7% accurate, 3.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 9 \cdot 10^{+17}:\\
\;\;\;\;\sin re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 9e17

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 68.0%

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

    if 9e17 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 59.9%

      \[\leadsto \color{blue}{0.25 \cdot \left({im}^{2} \cdot \sin re\right) + \left(0.5 \cdot \left(im \cdot \sin re\right) + 4.5 \cdot \sin re\right)} \]
    7. Step-by-step derivation
      1. associate-+r+59.9%

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

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

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

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

        \[\leadsto \sin re \cdot 4.5 + \left(\left(0.25 \cdot {im}^{2}\right) \cdot \sin re + \color{blue}{\left(0.5 \cdot im\right) \cdot \sin re}\right) \]
      6. distribute-rgt-out59.9%

        \[\leadsto \sin re \cdot 4.5 + \color{blue}{\sin re \cdot \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)} \]
      7. distribute-lft-out59.9%

        \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \]
      8. unpow259.9%

        \[\leadsto \sin re \cdot \left(4.5 + \left(0.25 \cdot \color{blue}{\left(im \cdot im\right)} + 0.5 \cdot im\right)\right) \]
      9. associate-*r*59.9%

        \[\leadsto \sin re \cdot \left(4.5 + \left(\color{blue}{\left(0.25 \cdot im\right) \cdot im} + 0.5 \cdot im\right)\right) \]
      10. distribute-rgt-out59.9%

        \[\leadsto \sin re \cdot \left(4.5 + \color{blue}{im \cdot \left(0.25 \cdot im + 0.5\right)}\right) \]
    8. Simplified59.9%

      \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + im \cdot \left(0.25 \cdot im + 0.5\right)\right)} \]
    9. Taylor expanded in re around 0 53.8%

      \[\leadsto \color{blue}{re \cdot \left(4.5 + im \cdot \left(0.5 + 0.25 \cdot im\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{+17}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 13: 38.0% accurate, 23.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;re\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

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

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def83.2%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Simplified83.2%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Taylor expanded in re around 0 48.3%

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 \cdot re\right) \]
      5. fma-def48.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re\right) \]
    9. Simplified48.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)} \]
    10. Taylor expanded in im around 0 34.6%

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

    if 125 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in im around 0 57.9%

      \[\leadsto \color{blue}{0.25 \cdot \left({im}^{2} \cdot \sin re\right) + \left(0.5 \cdot \left(im \cdot \sin re\right) + 4.5 \cdot \sin re\right)} \]
    7. Step-by-step derivation
      1. associate-+r+57.9%

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

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

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

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

        \[\leadsto \sin re \cdot 4.5 + \left(\left(0.25 \cdot {im}^{2}\right) \cdot \sin re + \color{blue}{\left(0.5 \cdot im\right) \cdot \sin re}\right) \]
      6. distribute-rgt-out57.9%

        \[\leadsto \sin re \cdot 4.5 + \color{blue}{\sin re \cdot \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)} \]
      7. distribute-lft-out57.9%

        \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \]
      8. unpow257.9%

        \[\leadsto \sin re \cdot \left(4.5 + \left(0.25 \cdot \color{blue}{\left(im \cdot im\right)} + 0.5 \cdot im\right)\right) \]
      9. associate-*r*57.9%

        \[\leadsto \sin re \cdot \left(4.5 + \left(\color{blue}{\left(0.25 \cdot im\right) \cdot im} + 0.5 \cdot im\right)\right) \]
      10. distribute-rgt-out57.9%

        \[\leadsto \sin re \cdot \left(4.5 + \color{blue}{im \cdot \left(0.25 \cdot im + 0.5\right)}\right) \]
    8. Simplified57.9%

      \[\leadsto \color{blue}{\sin re \cdot \left(4.5 + im \cdot \left(0.25 \cdot im + 0.5\right)\right)} \]
    9. Taylor expanded in re around 0 52.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 14: 30.0% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 600:\\
\;\;\;\;re\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

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

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def83.2%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Simplified83.2%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Taylor expanded in re around 0 48.3%

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 \cdot re\right) \]
      5. fma-def48.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re\right) \]
    9. Simplified48.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)} \]
    10. Taylor expanded in im around 0 34.6%

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

    if 600 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

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

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)} \]
    5. Applied egg-rr100.0%

      \[\leadsto \sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \color{blue}{8}\right) \]
    6. Taylor expanded in re around 0 77.2%

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left(im \cdot 0.5 + 4.5\right)} \]
    9. Simplified20.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 600:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(4.5 + 0.5 \cdot im\right)\\ \end{array} \]

Alternative 15: 26.8% accurate, 309.0× speedup?

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

\\
re
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-lft-in100.0%

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

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
    3. cancel-sign-sub100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
    4. distribute-lft-neg-out100.0%

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

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
    6. distribute-rgt-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
    7. neg-mul-1100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    8. associate-*r*100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    9. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
    11. neg-sub0100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
    12. *-commutative100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
    13. neg-mul-1100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
    14. remove-double-neg100.0%

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
    2. unpow277.5%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
    3. fma-def77.5%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
  6. Simplified77.5%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
  7. Taylor expanded in re around 0 49.2%

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

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

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

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

      \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 \cdot re\right) \]
    5. fma-def49.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re\right) \]
  9. Simplified49.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)} \]
  10. Taylor expanded in im around 0 27.6%

    \[\leadsto \color{blue}{re} \]
  11. Final simplification27.6%

    \[\leadsto re \]

Reproduce

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