math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 11.5s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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. *-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\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: 81.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(re, e^{im}, \frac{re}{e^{im}}\right)\\

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


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re + \mathsf{fma}\left(0.001388888888888889, \sin re \cdot {im}^{6}, \sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 0.041666666666666664 \cdot {im}^{4}\right)\right)} \]
    6. Taylor expanded in re around inf 93.4%

      \[\leadsto \sin re + \color{blue}{\left(0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right) + \sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*93.4%

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

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

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

        \[\leadsto \sin re + \sin re \cdot \left(\color{blue}{{im}^{6} \cdot 0.001388888888888889} + \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)\right) \]
      5. fma-def93.4%

        \[\leadsto \sin re + \sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{6}, 0.001388888888888889, 0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)} \]
      6. fma-def93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \color{blue}{\mathsf{fma}\left(0.041666666666666664, {im}^{4}, 0.5 \cdot {im}^{2}\right)}\right) \]
      7. unpow293.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, 0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right) \]
      8. *-commutative93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, \color{blue}{\left(im \cdot im\right) \cdot 0.5}\right)\right) \]
      9. associate-*l*93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, \color{blue}{im \cdot \left(im \cdot 0.5\right)}\right)\right) \]
    8. Simplified93.4%

      \[\leadsto \sin re + \color{blue}{\sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, im \cdot \left(im \cdot 0.5\right)\right)\right)} \]
    9. Taylor expanded in im around 0 82.0%

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

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

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

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

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

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

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

    if 0.0359999999999999973 < im < 1.55e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)\right)\right)} \]
      2. expm1-udef37.1%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot \left(e^{im} + e^{-im}\right)\right)} - 1 \]
      4. cosh-undef37.1%

        \[\leadsto e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1 \]
    7. Applied egg-rr37.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p80.0%

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

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

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

        \[\leadsto re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    9. Simplified80.0%

      \[\leadsto \color{blue}{re \cdot \left(1 \cdot \cosh im\right)} \]
    10. Taylor expanded in re around 0 80.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + \frac{1}{e^{im}}\right)\right)} \]
    11. Step-by-step derivation
      1. distribute-lft-in80.0%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(re, e^{im}, re \cdot \frac{1}{e^{im}}\right)} \]
      3. associate-*r/80.0%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(re, e^{im}, \color{blue}{\frac{re \cdot 1}{e^{im}}}\right) \]
      4. *-rgt-identity80.0%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(re, e^{im}, \frac{\color{blue}{re}}{e^{im}}\right) \]
    12. Simplified80.0%

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

    if 1.55e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.7% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \cosh im\\

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


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re + \mathsf{fma}\left(0.001388888888888889, \sin re \cdot {im}^{6}, \sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 0.041666666666666664 \cdot {im}^{4}\right)\right)} \]
    6. Taylor expanded in re around inf 93.4%

      \[\leadsto \sin re + \color{blue}{\left(0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right) + \sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*93.4%

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

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

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

        \[\leadsto \sin re + \sin re \cdot \left(\color{blue}{{im}^{6} \cdot 0.001388888888888889} + \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)\right) \]
      5. fma-def93.4%

        \[\leadsto \sin re + \sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{6}, 0.001388888888888889, 0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)} \]
      6. fma-def93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \color{blue}{\mathsf{fma}\left(0.041666666666666664, {im}^{4}, 0.5 \cdot {im}^{2}\right)}\right) \]
      7. unpow293.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, 0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right) \]
      8. *-commutative93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, \color{blue}{\left(im \cdot im\right) \cdot 0.5}\right)\right) \]
      9. associate-*l*93.4%

        \[\leadsto \sin re + \sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, \color{blue}{im \cdot \left(im \cdot 0.5\right)}\right)\right) \]
    8. Simplified93.4%

      \[\leadsto \sin re + \color{blue}{\sin re \cdot \mathsf{fma}\left({im}^{6}, 0.001388888888888889, \mathsf{fma}\left(0.041666666666666664, {im}^{4}, im \cdot \left(im \cdot 0.5\right)\right)\right)} \]
    9. Taylor expanded in im around 0 82.0%

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

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

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

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

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

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

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

    if 0.048000000000000001 < im < 1.55e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)\right)\right)} \]
      2. expm1-udef37.1%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot \left(e^{im} + e^{-im}\right)\right)} - 1 \]
      4. cosh-undef37.1%

        \[\leadsto e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1 \]
    7. Applied egg-rr37.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p80.0%

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

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

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

        \[\leadsto re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    9. Simplified80.0%

      \[\leadsto \color{blue}{re \cdot \left(1 \cdot \cosh im\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-udef37.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)} - 1} \]
      3. *-un-lft-identity37.1%

        \[\leadsto e^{\mathsf{log1p}\left(re \cdot \color{blue}{\cosh im}\right)} - 1 \]
    11. Applied egg-rr37.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \cosh im\right)} - 1} \]
    12. Step-by-step derivation
      1. expm1-def37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \cosh im\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{re \cdot \cosh im} \]
    13. Simplified80.0%

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

    if 1.55e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.048:\\ \;\;\;\;\sin re + im \cdot \left(\sin re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \cosh im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]

Alternative 4: 84.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.07 \lor \neg \left(im \leq 1.55 \cdot 10^{+152}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \cosh im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 0.07) (not (<= im 1.55e+152)))
   (* (* 0.5 (sin re)) (+ 2.0 (* im im)))
   (* re (cosh im))))
double code(double re, double im) {
	double tmp;
	if ((im <= 0.07) || !(im <= 1.55e+152)) {
		tmp = (0.5 * sin(re)) * (2.0 + (im * im));
	} 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.07d0) .or. (.not. (im <= 1.55d+152))) then
        tmp = (0.5d0 * sin(re)) * (2.0d0 + (im * im))
    else
        tmp = re * cosh(im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= 0.07) || !(im <= 1.55e+152)) {
		tmp = (0.5 * Math.sin(re)) * (2.0 + (im * im));
	} else {
		tmp = re * Math.cosh(im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 0.07) or not (im <= 1.55e+152):
		tmp = (0.5 * math.sin(re)) * (2.0 + (im * im))
	else:
		tmp = re * math.cosh(im)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 0.07) || !(im <= 1.55e+152))
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.0 + Float64(im * im)));
	else
		tmp = Float64(re * cosh(im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= 0.07) || ~((im <= 1.55e+152)))
		tmp = (0.5 * sin(re)) * (2.0 + (im * im));
	else
		tmp = re * cosh(im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, 0.07], N[Not[LessEqual[im, 1.55e+152]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.07 \lor \neg \left(im \leq 1.55 \cdot 10^{+152}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 0.070000000000000007 or 1.55e152 < im

    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. *-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.070000000000000007 < im < 1.55e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)\right)\right)} \]
      2. expm1-udef37.1%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot \left(e^{im} + e^{-im}\right)\right)} - 1 \]
      4. cosh-undef37.1%

        \[\leadsto e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1 \]
    7. Applied egg-rr37.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p80.0%

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

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

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

        \[\leadsto re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    9. Simplified80.0%

      \[\leadsto \color{blue}{re \cdot \left(1 \cdot \cosh im\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-udef37.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)} - 1} \]
      3. *-un-lft-identity37.1%

        \[\leadsto e^{\mathsf{log1p}\left(re \cdot \color{blue}{\cosh im}\right)} - 1 \]
    11. Applied egg-rr37.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \cosh im\right)} - 1} \]
    12. Step-by-step derivation
      1. expm1-def37.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \cosh im\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{re \cdot \cosh im} \]
    13. Simplified80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.07 \lor \neg \left(im \leq 1.55 \cdot 10^{+152}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \cosh im\\ \end{array} \]

Alternative 5: 69.4% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.0115:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \cosh im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.0115) (sin re) (* re (cosh im))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.0115) {
		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.0115d0) 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.0115) {
		tmp = Math.sin(re);
	} else {
		tmp = re * Math.cosh(im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.0115:
		tmp = math.sin(re)
	else:
		tmp = re * math.cosh(im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.0115)
		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.0115)
		tmp = sin(re);
	else
		tmp = re * cosh(im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.0115], N[Sin[re], $MachinePrecision], N[(re * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0115 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u36.4%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(re \cdot 0.5\right)} \cdot \left(e^{im} + e^{-im}\right)\right)} - 1 \]
      4. cosh-undef36.4%

        \[\leadsto e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1 \]
    7. Applied egg-rr36.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def36.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(re \cdot 0.5\right) \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p78.8%

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

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

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

        \[\leadsto re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    9. Simplified78.8%

      \[\leadsto \color{blue}{re \cdot \left(1 \cdot \cosh im\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u36.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-udef36.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \left(1 \cdot \cosh im\right)\right)} - 1} \]
      3. *-un-lft-identity36.4%

        \[\leadsto e^{\mathsf{log1p}\left(re \cdot \color{blue}{\cosh im}\right)} - 1 \]
    11. Applied egg-rr36.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \cosh im\right)} - 1} \]
    12. Step-by-step derivation
      1. expm1-def36.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \cosh im\right)\right)} \]
      2. expm1-log1p78.8%

        \[\leadsto \color{blue}{re \cdot \cosh im} \]
    13. Simplified78.8%

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

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

Alternative 6: 61.6% accurate, 3.0× speedup?

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

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

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


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0210000000000000013 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 47.5% accurate, 27.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -7.2 \cdot 10^{+201}:\\ \;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re + re \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -7.2e+201)
   (+ 0.08333333333333333 (* re (* re 0.016666666666666666)))
   (+ re (* re (* im (* 0.5 im))))))
double code(double re, double im) {
	double tmp;
	if (re <= -7.2e+201) {
		tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
	} else {
		tmp = re + (re * (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 <= (-7.2d+201)) then
        tmp = 0.08333333333333333d0 + (re * (re * 0.016666666666666666d0))
    else
        tmp = re + (re * (im * (0.5d0 * im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -7.2e+201) {
		tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
	} else {
		tmp = re + (re * (im * (0.5 * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -7.2e+201:
		tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666))
	else:
		tmp = re + (re * (im * (0.5 * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -7.2e+201)
		tmp = Float64(0.08333333333333333 + Float64(re * Float64(re * 0.016666666666666666)));
	else
		tmp = Float64(re + Float64(re * Float64(im * Float64(0.5 * im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -7.2e+201)
		tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
	else
		tmp = re + (re * (im * (0.5 * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -7.2e+201], N[(0.08333333333333333 + N[(re * N[(re * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + N[(re * N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -7.2 \cdot 10^{+201}:\\
\;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -7.19999999999999951e201

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
    5. Taylor expanded in re around 0 29.3%

      \[\leadsto \color{blue}{0.08333333333333333 + \left(0.016666666666666666 \cdot {re}^{2} + 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
    6. Step-by-step derivation
      1. *-commutative29.3%

        \[\leadsto 0.08333333333333333 + \left(\color{blue}{{re}^{2} \cdot 0.016666666666666666} + 0.25 \cdot \frac{1}{{re}^{2}}\right) \]
      2. fma-def29.3%

        \[\leadsto 0.08333333333333333 + \color{blue}{\mathsf{fma}\left({re}^{2}, 0.016666666666666666, 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
      3. unpow229.3%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(\color{blue}{re \cdot re}, 0.016666666666666666, 0.25 \cdot \frac{1}{{re}^{2}}\right) \]
      4. associate-*r/29.3%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}}\right) \]
      5. metadata-eval29.3%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{\color{blue}{0.25}}{{re}^{2}}\right) \]
      6. unpow229.3%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{0.25}{\color{blue}{re \cdot re}}\right) \]
    7. Simplified29.3%

      \[\leadsto \color{blue}{0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{0.25}{re \cdot re}\right)} \]
    8. Taylor expanded in re around inf 29.3%

      \[\leadsto 0.08333333333333333 + \color{blue}{0.016666666666666666 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow229.3%

        \[\leadsto 0.08333333333333333 + 0.016666666666666666 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative29.3%

        \[\leadsto 0.08333333333333333 + \color{blue}{\left(re \cdot re\right) \cdot 0.016666666666666666} \]
      3. associate-*l*29.3%

        \[\leadsto 0.08333333333333333 + \color{blue}{re \cdot \left(re \cdot 0.016666666666666666\right)} \]
    10. Simplified29.3%

      \[\leadsto 0.08333333333333333 + \color{blue}{re \cdot \left(re \cdot 0.016666666666666666\right)} \]

    if -7.19999999999999951e201 < re

    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. *-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -7.2 \cdot 10^{+201}:\\ \;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re + re \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 29.5% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6 \cdot 10^{+36}:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;\frac{0.5}{re} \cdot \frac{0.5}{re}\\


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6000000000000001e36 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
    5. Taylor expanded in re around 0 18.2%

      \[\leadsto \color{blue}{\frac{0.25}{{re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow218.2%

        \[\leadsto \frac{0.25}{\color{blue}{re \cdot re}} \]
    7. Simplified18.2%

      \[\leadsto \color{blue}{\frac{0.25}{re \cdot re}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt18.2%

        \[\leadsto \color{blue}{\sqrt{\frac{0.25}{re \cdot re}} \cdot \sqrt{\frac{0.25}{re \cdot re}}} \]
      2. sqrt-div18.2%

        \[\leadsto \color{blue}{\frac{\sqrt{0.25}}{\sqrt{re \cdot re}}} \cdot \sqrt{\frac{0.25}{re \cdot re}} \]
      3. metadata-eval18.2%

        \[\leadsto \frac{\color{blue}{0.5}}{\sqrt{re \cdot re}} \cdot \sqrt{\frac{0.25}{re \cdot re}} \]
      4. sqrt-prod17.7%

        \[\leadsto \frac{0.5}{\color{blue}{\sqrt{re} \cdot \sqrt{re}}} \cdot \sqrt{\frac{0.25}{re \cdot re}} \]
      5. add-sqr-sqrt29.2%

        \[\leadsto \frac{0.5}{\color{blue}{re}} \cdot \sqrt{\frac{0.25}{re \cdot re}} \]
      6. sqrt-div29.2%

        \[\leadsto \frac{0.5}{re} \cdot \color{blue}{\frac{\sqrt{0.25}}{\sqrt{re \cdot re}}} \]
      7. metadata-eval29.2%

        \[\leadsto \frac{0.5}{re} \cdot \frac{\color{blue}{0.5}}{\sqrt{re \cdot re}} \]
      8. sqrt-prod17.7%

        \[\leadsto \frac{0.5}{re} \cdot \frac{0.5}{\color{blue}{\sqrt{re} \cdot \sqrt{re}}} \]
      9. add-sqr-sqrt18.2%

        \[\leadsto \frac{0.5}{re} \cdot \frac{0.5}{\color{blue}{re}} \]
    9. Applied egg-rr18.2%

      \[\leadsto \color{blue}{\frac{0.5}{re} \cdot \frac{0.5}{re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{+36}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{re} \cdot \frac{0.5}{re}\\ \end{array} \]

Alternative 9: 29.7% accurate, 34.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 250 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
    5. Taylor expanded in re around 0 35.7%

      \[\leadsto \color{blue}{0.08333333333333333 + \left(0.016666666666666666 \cdot {re}^{2} + 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
    6. Step-by-step derivation
      1. *-commutative35.7%

        \[\leadsto 0.08333333333333333 + \left(\color{blue}{{re}^{2} \cdot 0.016666666666666666} + 0.25 \cdot \frac{1}{{re}^{2}}\right) \]
      2. fma-def35.7%

        \[\leadsto 0.08333333333333333 + \color{blue}{\mathsf{fma}\left({re}^{2}, 0.016666666666666666, 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
      3. unpow235.7%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(\color{blue}{re \cdot re}, 0.016666666666666666, 0.25 \cdot \frac{1}{{re}^{2}}\right) \]
      4. associate-*r/35.7%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}}\right) \]
      5. metadata-eval35.7%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{\color{blue}{0.25}}{{re}^{2}}\right) \]
      6. unpow235.7%

        \[\leadsto 0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{0.25}{\color{blue}{re \cdot re}}\right) \]
    7. Simplified35.7%

      \[\leadsto \color{blue}{0.08333333333333333 + \mathsf{fma}\left(re \cdot re, 0.016666666666666666, \frac{0.25}{re \cdot re}\right)} \]
    8. Taylor expanded in re around inf 21.0%

      \[\leadsto 0.08333333333333333 + \color{blue}{0.016666666666666666 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow221.0%

        \[\leadsto 0.08333333333333333 + 0.016666666666666666 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative21.0%

        \[\leadsto 0.08333333333333333 + \color{blue}{\left(re \cdot re\right) \cdot 0.016666666666666666} \]
      3. associate-*l*21.0%

        \[\leadsto 0.08333333333333333 + \color{blue}{re \cdot \left(re \cdot 0.016666666666666666\right)} \]
    10. Simplified21.0%

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

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

Alternative 10: 29.5% accurate, 43.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.7 \cdot 10^{+36}:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\


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

    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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.70000000000000029e36 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
    5. Taylor expanded in re around 0 18.2%

      \[\leadsto \color{blue}{\frac{0.25}{{re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow218.2%

        \[\leadsto \frac{0.25}{\color{blue}{re \cdot re}} \]
    7. Simplified18.2%

      \[\leadsto \color{blue}{\frac{0.25}{re \cdot re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+36}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{re \cdot re}\\ \end{array} \]

Alternative 11: 4.3% accurate, 309.0× speedup?

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

\\
0.08333333333333333
\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. *-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
  5. Taylor expanded in re around 0 10.7%

    \[\leadsto \color{blue}{0.08333333333333333 + 0.25 \cdot \frac{1}{{re}^{2}}} \]
  6. Step-by-step derivation
    1. associate-*r/10.7%

      \[\leadsto 0.08333333333333333 + \color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}} \]
    2. metadata-eval10.7%

      \[\leadsto 0.08333333333333333 + \frac{\color{blue}{0.25}}{{re}^{2}} \]
    3. unpow210.7%

      \[\leadsto 0.08333333333333333 + \frac{0.25}{\color{blue}{re \cdot re}} \]
  7. Simplified10.7%

    \[\leadsto \color{blue}{0.08333333333333333 + \frac{0.25}{re \cdot re}} \]
  8. Taylor expanded in re around inf 5.0%

    \[\leadsto \color{blue}{0.08333333333333333} \]
  9. Final simplification5.0%

    \[\leadsto 0.08333333333333333 \]

Alternative 12: 26.7% 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. *-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto re \]

Reproduce

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