math.sin on complex, real part

Percentage Accurate: 99.9% → 99.9%
Time: 10.1s
Alternatives: 11
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 11 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: 99.9% 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: 99.9% accurate, 1.0× speedup?

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

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

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

      \[\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. cancel-sign-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.6% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{if}\;im \leq 0.0295:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+117}:\\ \;\;\;\;re \cdot \cosh im\\ \mathbf{else}:\\ \;\;\;\;\langle \left( \langle \left( t_0 \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (sin re) (+ 1.0 (* im (* 0.5 im))))))
   (if (<= im 0.0295)
     t_0
     (if (<= im 3.3e+117)
       (* re (cosh im))
       (cast (! :precision binary32 (cast (! :precision binary64 t_0))))))))
double code(double re, double im) {
	double t_0 = sin(re) * (1.0 + (im * (0.5 * im)));
	double tmp;
	if (im <= 0.0295) {
		tmp = t_0;
	} else if (im <= 3.3e+117) {
		tmp = re * cosh(im);
	} else {
		double tmp_3 = t_0;
		double tmp_2 = (float) tmp_3;
		tmp = (double) tmp_2;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    t_0 = sin(re) * (1.0d0 + (im * (0.5d0 * im)))
    if (im <= 0.0295d0) then
        tmp = t_0
    else if (im <= 3.3d+117) then
        tmp = re * cosh(im)
    else
        tmp_3 = t_0
        tmp_2 = real(tmp_3, 4)
        tmp = real(tmp_2, 8)
    end if
    code = tmp
end function
function code(re, im)
	t_0 = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 * im))))
	tmp = 0.0
	if (im <= 0.0295)
		tmp = t_0;
	elseif (im <= 3.3e+117)
		tmp = Float64(re * cosh(im));
	else
		tmp_3 = t_0
		tmp_2 = Float32(tmp_3)
		tmp = Float64(tmp_2);
	end
	return tmp
end
function tmp_5 = code(re, im)
	t_0 = sin(re) * (1.0 + (im * (0.5 * im)));
	tmp = 0.0;
	if (im <= 0.0295)
		tmp = t_0;
	elseif (im <= 3.3e+117)
		tmp = re * cosh(im);
	else
		tmp_4 = t_0;
		tmp_3 = single(tmp_4);
		tmp = double(tmp_3);
	end
	tmp_5 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{if}\;im \leq 0.0295:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+117}:\\
\;\;\;\;re \cdot \cosh im\\

\mathbf{else}:\\
\;\;\;\;\langle \left( \langle \left( t_0 \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.029499999999999998 < im < 3.2999999999999998e117

    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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 re around 0 88.2%

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

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

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot re\right) \cdot \left({\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}\right)}{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}} \]
      3. associate-/l*5.8%

        \[\leadsto \color{blue}{\frac{0.5 \cdot re}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}}} \]
      4. *-commutative5.8%

        \[\leadsto \frac{\color{blue}{re \cdot 0.5}}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}} \]
      5. clear-num5.8%

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

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{-im} + e^{im}}}} \]
      7. +-commutative88.2%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{im} + e^{-im}}}} \]
      8. cosh-undef88.2%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{2 \cdot \cosh im}}} \]
    6. Applied egg-rr88.2%

      \[\leadsto \color{blue}{\frac{re \cdot 0.5}{\frac{1}{2 \cdot \cosh im}}} \]
    7. Step-by-step derivation
      1. associate-/l*88.2%

        \[\leadsto \color{blue}{\frac{re}{\frac{\frac{1}{2 \cdot \cosh im}}{0.5}}} \]
      2. associate-/r*88.2%

        \[\leadsto \frac{re}{\frac{\color{blue}{\frac{\frac{1}{2}}{\cosh im}}}{0.5}} \]
      3. metadata-eval88.2%

        \[\leadsto \frac{re}{\frac{\frac{\color{blue}{0.5}}{\cosh im}}{0.5}} \]
    8. Simplified88.2%

      \[\leadsto \color{blue}{\frac{re}{\frac{\frac{0.5}{\cosh im}}{0.5}}} \]
    9. Step-by-step derivation
      1. clear-num88.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\frac{0.5}{\cosh im}}{0.5}}{re}}} \]
      2. associate-/r/88.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{0.5}{\cosh im}}{0.5}} \cdot re} \]
      3. clear-num88.2%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{0.5}{\cosh im}}} \cdot re \]
      4. associate-/r/88.2%

        \[\leadsto \color{blue}{\left(\frac{0.5}{0.5} \cdot \cosh im\right)} \cdot re \]
      5. metadata-eval88.2%

        \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot re \]
      6. *-lft-identity88.2%

        \[\leadsto \color{blue}{\cosh im} \cdot re \]
    10. Applied egg-rr88.2%

      \[\leadsto \color{blue}{\cosh im \cdot re} \]

    if 3.2999999999999998e117 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 85.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \]
    7. Step-by-step derivation
      1. rewrite-binary64/binary32-simplify100.0%

        \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
    8. Applied rewrite-once100.0%

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.0295:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+117}:\\ \;\;\;\;re \cdot \cosh im\\ \mathbf{else}:\\ \;\;\;\;\langle \left( \langle \left( \sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \end{array} \]

Alternative 3: 84.1% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.082:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0820000000000000034 < im < 1.35000000000000003e154

    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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 re around 0 75.0%

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

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

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot re\right) \cdot \left({\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}\right)}{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}} \]
      3. associate-/l*4.1%

        \[\leadsto \color{blue}{\frac{0.5 \cdot re}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}}} \]
      4. *-commutative4.1%

        \[\leadsto \frac{\color{blue}{re \cdot 0.5}}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}} \]
      5. clear-num4.1%

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

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{-im} + e^{im}}}} \]
      7. +-commutative75.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{im} + e^{-im}}}} \]
      8. cosh-undef75.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{2 \cdot \cosh im}}} \]
    6. Applied egg-rr75.0%

      \[\leadsto \color{blue}{\frac{re \cdot 0.5}{\frac{1}{2 \cdot \cosh im}}} \]
    7. Step-by-step derivation
      1. associate-/l*75.0%

        \[\leadsto \color{blue}{\frac{re}{\frac{\frac{1}{2 \cdot \cosh im}}{0.5}}} \]
      2. associate-/r*75.0%

        \[\leadsto \frac{re}{\frac{\color{blue}{\frac{\frac{1}{2}}{\cosh im}}}{0.5}} \]
      3. metadata-eval75.0%

        \[\leadsto \frac{re}{\frac{\frac{\color{blue}{0.5}}{\cosh im}}{0.5}} \]
    8. Simplified75.0%

      \[\leadsto \color{blue}{\frac{re}{\frac{\frac{0.5}{\cosh im}}{0.5}}} \]
    9. Step-by-step derivation
      1. clear-num74.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\frac{0.5}{\cosh im}}{0.5}}{re}}} \]
      2. associate-/r/75.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{0.5}{\cosh im}}{0.5}} \cdot re} \]
      3. clear-num75.0%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{0.5}{\cosh im}}} \cdot re \]
      4. associate-/r/75.0%

        \[\leadsto \color{blue}{\left(\frac{0.5}{0.5} \cdot \cosh im\right)} \cdot re \]
      5. metadata-eval75.0%

        \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot re \]
      6. *-lft-identity75.0%

        \[\leadsto \color{blue}{\cosh im} \cdot re \]
    10. Applied egg-rr75.0%

      \[\leadsto \color{blue}{\cosh im \cdot re} \]

    if 1.35000000000000003e154 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 \color{blue}{\sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    5. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sin re \cdot {im}^{2}} \]
      2. unpow2100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.082:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \cosh im\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 4: 71.2% accurate, 2.8× speedup?

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

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0106 < im < 1.35000000000000003e154

    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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 re around 0 75.0%

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

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

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot re\right) \cdot \left({\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}\right)}{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}} \]
      3. associate-/l*4.1%

        \[\leadsto \color{blue}{\frac{0.5 \cdot re}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}}} \]
      4. *-commutative4.1%

        \[\leadsto \frac{\color{blue}{re \cdot 0.5}}{\frac{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}{{\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}}} \]
      5. clear-num4.1%

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

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{-im} + e^{im}}}} \]
      7. +-commutative75.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{im} + e^{-im}}}} \]
      8. cosh-undef75.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{2 \cdot \cosh im}}} \]
    6. Applied egg-rr75.0%

      \[\leadsto \color{blue}{\frac{re \cdot 0.5}{\frac{1}{2 \cdot \cosh im}}} \]
    7. Step-by-step derivation
      1. associate-/l*75.0%

        \[\leadsto \color{blue}{\frac{re}{\frac{\frac{1}{2 \cdot \cosh im}}{0.5}}} \]
      2. associate-/r*75.0%

        \[\leadsto \frac{re}{\frac{\color{blue}{\frac{\frac{1}{2}}{\cosh im}}}{0.5}} \]
      3. metadata-eval75.0%

        \[\leadsto \frac{re}{\frac{\frac{\color{blue}{0.5}}{\cosh im}}{0.5}} \]
    8. Simplified75.0%

      \[\leadsto \color{blue}{\frac{re}{\frac{\frac{0.5}{\cosh im}}{0.5}}} \]
    9. Step-by-step derivation
      1. clear-num74.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\frac{0.5}{\cosh im}}{0.5}}{re}}} \]
      2. associate-/r/75.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{0.5}{\cosh im}}{0.5}} \cdot re} \]
      3. clear-num75.0%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{0.5}{\cosh im}}} \cdot re \]
      4. associate-/r/75.0%

        \[\leadsto \color{blue}{\left(\frac{0.5}{0.5} \cdot \cosh im\right)} \cdot re \]
      5. metadata-eval75.0%

        \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot re \]
      6. *-lft-identity75.0%

        \[\leadsto \color{blue}{\cosh im} \cdot re \]
    10. Applied egg-rr75.0%

      \[\leadsto \color{blue}{\cosh im \cdot re} \]

    if 1.35000000000000003e154 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 \color{blue}{\sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    5. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sin re \cdot {im}^{2}} \]
      2. unpow2100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.0106:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \cosh im\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 5: 67.8% accurate, 2.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;re \cdot \cosh im\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.017500000000000002 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 re around 0 77.0%

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

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

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot re\right) \cdot \left({\left(e^{-im}\right)}^{3} + {\left(e^{im}\right)}^{3}\right)}{e^{-im} \cdot e^{-im} + \left(e^{im} \cdot e^{im} - e^{-im} \cdot e^{im}\right)}} \]
      3. associate-/l*1.6%

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

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

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

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{-im} + e^{im}}}} \]
      7. +-commutative77.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{e^{im} + e^{-im}}}} \]
      8. cosh-undef77.0%

        \[\leadsto \frac{re \cdot 0.5}{\frac{1}{\color{blue}{2 \cdot \cosh im}}} \]
    6. Applied egg-rr77.0%

      \[\leadsto \color{blue}{\frac{re \cdot 0.5}{\frac{1}{2 \cdot \cosh im}}} \]
    7. Step-by-step derivation
      1. associate-/l*77.0%

        \[\leadsto \color{blue}{\frac{re}{\frac{\frac{1}{2 \cdot \cosh im}}{0.5}}} \]
      2. associate-/r*77.0%

        \[\leadsto \frac{re}{\frac{\color{blue}{\frac{\frac{1}{2}}{\cosh im}}}{0.5}} \]
      3. metadata-eval77.0%

        \[\leadsto \frac{re}{\frac{\frac{\color{blue}{0.5}}{\cosh im}}{0.5}} \]
    8. Simplified77.0%

      \[\leadsto \color{blue}{\frac{re}{\frac{\frac{0.5}{\cosh im}}{0.5}}} \]
    9. Step-by-step derivation
      1. clear-num77.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\frac{0.5}{\cosh im}}{0.5}}{re}}} \]
      2. associate-/r/77.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{0.5}{\cosh im}}{0.5}} \cdot re} \]
      3. clear-num77.0%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{0.5}{\cosh im}}} \cdot re \]
      4. associate-/r/77.0%

        \[\leadsto \color{blue}{\left(\frac{0.5}{0.5} \cdot \cosh im\right)} \cdot re \]
      5. metadata-eval77.0%

        \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot re \]
      6. *-lft-identity77.0%

        \[\leadsto \color{blue}{\cosh im} \cdot re \]
    10. Applied egg-rr77.0%

      \[\leadsto \color{blue}{\cosh im \cdot re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.0175:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \cosh im\\ \end{array} \]

Alternative 6: 60.5% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 9.8 \cdot 10^{+23}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6 \cdot 10^{+142}:\\ \;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(1 + im \cdot \left(0.5 \cdot im\right)\right) \cdot \left(2 \cdot \left(re \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 9.8e+23)
   (sin re)
   (if (<= im 6e+142)
     (+ re (* (* re (* re re)) -0.16666666666666666))
     (* (+ 1.0 (* im (* 0.5 im))) (* 2.0 (* re 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 9.8e+23) {
		tmp = sin(re);
	} else if (im <= 6e+142) {
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	} else {
		tmp = (1.0 + (im * (0.5 * im))) * (2.0 * (re * 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 <= 9.8d+23) then
        tmp = sin(re)
    else if (im <= 6d+142) then
        tmp = re + ((re * (re * re)) * (-0.16666666666666666d0))
    else
        tmp = (1.0d0 + (im * (0.5d0 * im))) * (2.0d0 * (re * 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 9.8e+23) {
		tmp = Math.sin(re);
	} else if (im <= 6e+142) {
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	} else {
		tmp = (1.0 + (im * (0.5 * im))) * (2.0 * (re * 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 9.8e+23:
		tmp = math.sin(re)
	elif im <= 6e+142:
		tmp = re + ((re * (re * re)) * -0.16666666666666666)
	else:
		tmp = (1.0 + (im * (0.5 * im))) * (2.0 * (re * 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 9.8e+23)
		tmp = sin(re);
	elseif (im <= 6e+142)
		tmp = Float64(re + Float64(Float64(re * Float64(re * re)) * -0.16666666666666666));
	else
		tmp = Float64(Float64(1.0 + Float64(im * Float64(0.5 * im))) * Float64(2.0 * Float64(re * 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 9.8e+23)
		tmp = sin(re);
	elseif (im <= 6e+142)
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	else
		tmp = (1.0 + (im * (0.5 * im))) * (2.0 * (re * 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 9.8e+23], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6e+142], N[(re + N[(N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(re * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 6 \cdot 10^{+142}:\\
\;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.8000000000000006e23 < im < 5.99999999999999949e142

    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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 2.5%

      \[\leadsto \color{blue}{\sin re} \]
    5. Taylor expanded in re around 0 25.3%

      \[\leadsto \color{blue}{re + -0.16666666666666666 \cdot {re}^{3}} \]
    6. Step-by-step derivation
      1. *-commutative25.3%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot -0.16666666666666666} \]
    7. Simplified25.3%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]
    8. Step-by-step derivation
      1. unpow325.3%

        \[\leadsto re + \color{blue}{\left(\left(re \cdot re\right) \cdot re\right)} \cdot -0.16666666666666666 \]
    9. Applied egg-rr25.3%

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

    if 5.99999999999999949e142 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 95.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \]
    7. Applied egg-rr95.1%

      \[\leadsto \color{blue}{\left(2 \cdot \sin re\right)} \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right) \]
    8. Applied egg-rr95.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 9.8 \cdot 10^{+23}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6 \cdot 10^{+142}:\\ \;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(1 + im \cdot \left(0.5 \cdot im\right)\right) \cdot \left(2 \cdot \left(re \cdot 2\right)\right)\\ \end{array} \]

Alternative 7: 48.3% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -3.6 \cdot 10^{+60} \lor \neg \left(re \leq 1.8 \cdot 10^{+91}\right):\\ \;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= re -3.6e+60) (not (<= re 1.8e+91)))
   (+ re (* (* re (* re re)) -0.16666666666666666))
   (* re (+ 1.0 (* im (* 0.5 im))))))
double code(double re, double im) {
	double tmp;
	if ((re <= -3.6e+60) || !(re <= 1.8e+91)) {
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	} else {
		tmp = re * (1.0 + (im * (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 ((re <= (-3.6d+60)) .or. (.not. (re <= 1.8d+91))) then
        tmp = re + ((re * (re * re)) * (-0.16666666666666666d0))
    else
        tmp = re * (1.0d0 + (im * (0.5d0 * im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((re <= -3.6e+60) || !(re <= 1.8e+91)) {
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	} else {
		tmp = re * (1.0 + (im * (0.5 * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (re <= -3.6e+60) or not (re <= 1.8e+91):
		tmp = re + ((re * (re * re)) * -0.16666666666666666)
	else:
		tmp = re * (1.0 + (im * (0.5 * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((re <= -3.6e+60) || !(re <= 1.8e+91))
		tmp = Float64(re + Float64(Float64(re * Float64(re * re)) * -0.16666666666666666));
	else
		tmp = Float64(re * Float64(1.0 + Float64(im * Float64(0.5 * im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((re <= -3.6e+60) || ~((re <= 1.8e+91)))
		tmp = re + ((re * (re * re)) * -0.16666666666666666);
	else
		tmp = re * (1.0 + (im * (0.5 * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[re, -3.6e+60], N[Not[LessEqual[re, 1.8e+91]], $MachinePrecision]], N[(re + N[(N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(re * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.6 \cdot 10^{+60} \lor \neg \left(re \leq 1.8 \cdot 10^{+91}\right):\\
\;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -3.59999999999999968e60 or 1.8e91 < re

    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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 54.6%

      \[\leadsto \color{blue}{\sin re} \]
    5. Taylor expanded in re around 0 27.9%

      \[\leadsto \color{blue}{re + -0.16666666666666666 \cdot {re}^{3}} \]
    6. Step-by-step derivation
      1. *-commutative27.9%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot -0.16666666666666666} \]
    7. Simplified27.9%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]
    8. Step-by-step derivation
      1. unpow327.9%

        \[\leadsto re + \color{blue}{\left(\left(re \cdot re\right) \cdot re\right)} \cdot -0.16666666666666666 \]
    9. Applied egg-rr27.9%

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

    if -3.59999999999999968e60 < re < 1.8e91

    1. Initial program 99.4%

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

        \[\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. cancel-sign-sub99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im\right) \cdot im}\right) \]
    6. Simplified79.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \]
    7. Taylor expanded in re around 0 66.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -3.6 \cdot 10^{+60} \lor \neg \left(re \leq 1.8 \cdot 10^{+91}\right):\\ \;\;\;\;re + \left(re \cdot \left(re \cdot re\right)\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 47.7% accurate, 34.3× speedup?

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

\\
re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)
\end{array}
Derivation
  1. Initial program 99.6%

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

      \[\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. cancel-sign-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im\right) \cdot im}\right) \]
  6. Simplified79.3%

    \[\leadsto \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \]
  7. Taylor expanded in re around 0 47.9%

    \[\leadsto \color{blue}{re} \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right) \]
  8. Final simplification47.9%

    \[\leadsto re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right) \]

Alternative 9: 36.7% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0105000000000000007 < 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. cancel-sign-sub100.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}} \]
      3. distribute-rgt-neg-out100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      12. 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)} \]
      13. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\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 62.5%

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

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

        \[\leadsto 1 \cdot \sin re + \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re} \]
      3. distribute-rgt-out62.5%

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

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

        \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im\right) \cdot im}\right) \]
    6. Simplified62.5%

      \[\leadsto \color{blue}{\sin re \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right)} \]
    7. Applied egg-rr61.7%

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

      \[\leadsto \left(2 \cdot \color{blue}{re}\right) \cdot \left(1 + \left(0.5 \cdot im\right) \cdot im\right) \]
    9. Taylor expanded in im around inf 49.5%

      \[\leadsto \color{blue}{{im}^{2} \cdot re} \]
    10. Step-by-step derivation
      1. *-commutative49.5%

        \[\leadsto \color{blue}{re \cdot {im}^{2}} \]
      2. unpow249.5%

        \[\leadsto re \cdot \color{blue}{\left(im \cdot im\right)} \]
    11. Simplified49.5%

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

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

Alternative 10: 4.1% accurate, 309.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 99.6%

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

      \[\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. cancel-sign-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3 - \sin re} \]
  5. Taylor expanded in re around 0 3.9%

    \[\leadsto \color{blue}{-3} \]
  6. Final simplification3.9%

    \[\leadsto -3 \]

Alternative 11: 26.2% 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 99.6%

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

      \[\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. cancel-sign-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  6. Final simplification25.5%

    \[\leadsto re \]

Reproduce

?
herbie shell --seed 2023297 
(FPCore (re im)
  :name "math.sin on complex, real part"
  :precision binary64
  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))