math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 12.0s
Alternatives: 16
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 16 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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.8% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < im < 1.2800000000000001e154

    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-in99.9%

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

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

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

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

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

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

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

        \[\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 75.0%

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

    if 1.2800000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.8% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < im < 1.2800000000000001e154

    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-in99.9%

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

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

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

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

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

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

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

        \[\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 75.0%

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

    if 1.2800000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2:\\ \;\;\;\;\sin re + 0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 4: 81.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+38}:\\ \;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 660.0)
   (* (sin re) (fma (* im im) 0.5 1.0))
   (if (<= im 3.25e+38)
     (+
      (/ 0.25 (* re re))
      (fma re (* re 0.016666666666666666) 0.08333333333333333))
     (if (<= im 1.28e+154)
       (+ re (* 0.041666666666666664 (* re (pow im 4.0))))
       (* 0.5 (* (sin re) (* im im)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = sin(re) * fma((im * im), 0.5, 1.0);
	} else if (im <= 3.25e+38) {
		tmp = (0.25 / (re * re)) + fma(re, (re * 0.016666666666666666), 0.08333333333333333);
	} else if (im <= 1.28e+154) {
		tmp = re + (0.041666666666666664 * (re * pow(im, 4.0)));
	} else {
		tmp = 0.5 * (sin(re) * (im * im));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 660.0)
		tmp = Float64(sin(re) * fma(Float64(im * im), 0.5, 1.0));
	elseif (im <= 3.25e+38)
		tmp = Float64(Float64(0.25 / Float64(re * re)) + fma(re, Float64(re * 0.016666666666666666), 0.08333333333333333));
	elseif (im <= 1.28e+154)
		tmp = Float64(re + Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))));
	else
		tmp = Float64(0.5 * Float64(sin(re) * Float64(im * im)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 660.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.25e+38], N[(N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(re * N[(re * 0.016666666666666666), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+154], N[(re + N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 3.25 \cdot 10^{+38}:\\
\;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\

\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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


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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({im}^{2}, 0.5, 1\right)} \cdot \sin re \]
      5. unpow282.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{im \cdot im}, 0.5, 1\right) \cdot \sin re \]
    8. Simplified82.8%

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

    if 660 < im < 3.25e38

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.25}{re \cdot re} + \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.016666666666666666 + 0.08333333333333333\right) \]
      9. associate-*l*50.1%

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

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

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

    if 3.25e38 < im < 1.2800000000000001e154

    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 \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    5. Taylor expanded in im around 0 48.0%

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

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

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

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

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

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

        \[\leadsto re + re \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot 0.5 + 0.041666666666666664 \cdot {im}^{4}\right) \]
    7. Simplified48.0%

      \[\leadsto \color{blue}{re + re \cdot \left(\left(im \cdot im\right) \cdot 0.5 + 0.041666666666666664 \cdot {im}^{4}\right)} \]
    8. Taylor expanded in im around inf 48.0%

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

    if 1.2800000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, 0.5, 1\right)\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+38}:\\ \;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 5: 69.2% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 700:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4 \cdot 10^{+38}:\\ \;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 700.0)
   (sin re)
   (if (<= im 4e+38)
     (+
      (/ 0.25 (* re re))
      (fma re (* re 0.016666666666666666) 0.08333333333333333))
     (if (<= im 1.28e+154)
       (+ re (* 0.041666666666666664 (* re (pow im 4.0))))
       (* 0.5 (* (sin re) (* im im)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 700.0) {
		tmp = sin(re);
	} else if (im <= 4e+38) {
		tmp = (0.25 / (re * re)) + fma(re, (re * 0.016666666666666666), 0.08333333333333333);
	} else if (im <= 1.28e+154) {
		tmp = re + (0.041666666666666664 * (re * pow(im, 4.0)));
	} else {
		tmp = 0.5 * (sin(re) * (im * im));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 700.0)
		tmp = sin(re);
	elseif (im <= 4e+38)
		tmp = Float64(Float64(0.25 / Float64(re * re)) + fma(re, Float64(re * 0.016666666666666666), 0.08333333333333333));
	elseif (im <= 1.28e+154)
		tmp = Float64(re + Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))));
	else
		tmp = Float64(0.5 * Float64(sin(re) * Float64(im * im)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4e+38], N[(N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(re * N[(re * 0.016666666666666666), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+154], N[(re + N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 4 \cdot 10^{+38}:\\
\;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\

\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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


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

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

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

    if 700 < im < 3.99999999999999991e38

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.25}{re \cdot re} + \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.016666666666666666 + 0.08333333333333333\right) \]
      9. associate-*l*50.1%

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

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

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

    if 3.99999999999999991e38 < im < 1.2800000000000001e154

    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 \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    5. Taylor expanded in im around 0 48.0%

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

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

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

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

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

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

        \[\leadsto re + re \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot 0.5 + 0.041666666666666664 \cdot {im}^{4}\right) \]
    7. Simplified48.0%

      \[\leadsto \color{blue}{re + re \cdot \left(\left(im \cdot im\right) \cdot 0.5 + 0.041666666666666664 \cdot {im}^{4}\right)} \]
    8. Taylor expanded in im around inf 48.0%

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

    if 1.2800000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 700:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4 \cdot 10^{+38}:\\ \;\;\;\;\frac{0.25}{re \cdot re} + \mathsf{fma}\left(re, re \cdot 0.016666666666666666, 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 6: 69.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 42000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+52}:\\ \;\;\;\;re + -0.16666666666666666 \cdot {re}^{3}\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 42000000.0)
   (sin re)
   (if (<= im 3.2e+52)
     (+ re (* -0.16666666666666666 (pow re 3.0)))
     (if (<= im 1.28e+154)
       (+ re (* 0.041666666666666664 (* re (pow im 4.0))))
       (* 0.5 (* (sin re) (* im im)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 42000000.0) {
		tmp = sin(re);
	} else if (im <= 3.2e+52) {
		tmp = re + (-0.16666666666666666 * pow(re, 3.0));
	} else if (im <= 1.28e+154) {
		tmp = re + (0.041666666666666664 * (re * pow(im, 4.0)));
	} else {
		tmp = 0.5 * (sin(re) * (im * im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 42000000.0d0) then
        tmp = sin(re)
    else if (im <= 3.2d+52) then
        tmp = re + ((-0.16666666666666666d0) * (re ** 3.0d0))
    else if (im <= 1.28d+154) then
        tmp = re + (0.041666666666666664d0 * (re * (im ** 4.0d0)))
    else
        tmp = 0.5d0 * (sin(re) * (im * im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 42000000.0) {
		tmp = Math.sin(re);
	} else if (im <= 3.2e+52) {
		tmp = re + (-0.16666666666666666 * Math.pow(re, 3.0));
	} else if (im <= 1.28e+154) {
		tmp = re + (0.041666666666666664 * (re * Math.pow(im, 4.0)));
	} else {
		tmp = 0.5 * (Math.sin(re) * (im * im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 42000000.0:
		tmp = math.sin(re)
	elif im <= 3.2e+52:
		tmp = re + (-0.16666666666666666 * math.pow(re, 3.0))
	elif im <= 1.28e+154:
		tmp = re + (0.041666666666666664 * (re * math.pow(im, 4.0)))
	else:
		tmp = 0.5 * (math.sin(re) * (im * im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 42000000.0)
		tmp = sin(re);
	elseif (im <= 3.2e+52)
		tmp = Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0)));
	elseif (im <= 1.28e+154)
		tmp = Float64(re + Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))));
	else
		tmp = Float64(0.5 * Float64(sin(re) * Float64(im * im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 42000000.0)
		tmp = sin(re);
	elseif (im <= 3.2e+52)
		tmp = re + (-0.16666666666666666 * (re ^ 3.0));
	elseif (im <= 1.28e+154)
		tmp = re + (0.041666666666666664 * (re * (im ^ 4.0)));
	else
		tmp = 0.5 * (sin(re) * (im * im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 42000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.2e+52], N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+154], N[(re + N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 3.2 \cdot 10^{+52}:\\
\;\;\;\;re + -0.16666666666666666 \cdot {re}^{3}\\

\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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


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

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

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

    if 4.2e7 < im < 3.2e52

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

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

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

    if 3.2e52 < im < 1.2800000000000001e154

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + re \cdot \left(\left(im \cdot im\right) \cdot 0.5 + 0.041666666666666664 \cdot {im}^{4}\right)} \]
    8. Taylor expanded in im around inf 51.4%

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

    if 1.2800000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 42000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.2 \cdot 10^{+52}:\\ \;\;\;\;re + -0.16666666666666666 \cdot {re}^{3}\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\ \;\;\;\;re + 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 7: 63.3% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+74}:\\
\;\;\;\;{re}^{-512}\\

\mathbf{elif}\;im \leq 1.3 \cdot 10^{+176}:\\
\;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\\

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


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

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

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

    if 900 < im < 1.7e74

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

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

      \[\leadsto \color{blue}{{re}^{-512}} \]

    if 1.7e74 < im < 1.29999999999999995e176

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

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

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

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

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

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

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

    if 1.29999999999999995e176 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 900:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+74}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+176}:\\ \;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(\sin re \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 65.9% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+131}:\\
\;\;\;\;{re}^{-512}\\

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


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

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

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

    if 1800 < im < 6.5e131

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

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

      \[\leadsto \color{blue}{{re}^{-512}} \]

    if 6.5e131 < 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 94.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1800:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+131}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 9: 62.8% accurate, 2.9× speedup?

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

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+74}:\\
\;\;\;\;{re}^{-512}\\

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


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

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

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

    if 960 < im < 1.79999999999999994e74

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

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

      \[\leadsto \color{blue}{{re}^{-512}} \]

    if 1.79999999999999994e74 < 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 79.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 960:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+74}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 10: 62.2% accurate, 3.0× speedup?

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

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

\mathbf{elif}\;im \leq 4.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\

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


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

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

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

    if 1150 < im < 4.19999999999999972e54

    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-rr21.0%

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{re \cdot re}} \]

    if 4.19999999999999972e54 < 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 71.5%

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

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

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

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

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

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

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

Alternative 11: 29.8% accurate, 27.8× speedup?

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

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

\mathbf{elif}\;im \leq 1.5 \cdot 10^{+236}:\\
\;\;\;\;\frac{0.25}{re \cdot re} + 0.08333333333333333\\

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


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

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

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

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

    if 850 < im < 1.4999999999999999e236

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.08333333333333333 + \frac{0.25}{re \cdot re}} \]

    if 1.4999999999999999e236 < 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 2.9%

      \[\leadsto \color{blue}{\sin re} \]
    5. Applied egg-rr1.9%

      \[\leadsto \color{blue}{-2 - -2 \cdot \cos \left(-2 \cdot re\right)} \]
    6. Taylor expanded in re around 0 20.5%

      \[\leadsto \color{blue}{-4 \cdot {re}^{2}} \]
    7. Step-by-step derivation
      1. unpow220.5%

        \[\leadsto -4 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative20.5%

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -4\right)} \]
    8. Simplified20.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 850:\\ \;\;\;\;re\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+236}:\\ \;\;\;\;\frac{0.25}{re \cdot re} + 0.08333333333333333\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot -4\right)\\ \end{array} \]

Alternative 12: 29.8% accurate, 33.9× speedup?

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

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

\mathbf{elif}\;im \leq 1.75 \cdot 10^{+236}:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\

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


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

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

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

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

    if 1100 < im < 1.7499999999999999e236

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

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

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

        \[\leadsto \frac{0.25}{\color{blue}{re \cdot re}} \]
    7. Simplified12.3%

      \[\leadsto \color{blue}{\frac{0.25}{re \cdot re}} \]

    if 1.7499999999999999e236 < 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 2.9%

      \[\leadsto \color{blue}{\sin re} \]
    5. Applied egg-rr1.9%

      \[\leadsto \color{blue}{-2 - -2 \cdot \cos \left(-2 \cdot re\right)} \]
    6. Taylor expanded in re around 0 20.5%

      \[\leadsto \color{blue}{-4 \cdot {re}^{2}} \]
    7. Step-by-step derivation
      1. unpow220.5%

        \[\leadsto -4 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative20.5%

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -4\right)} \]
    8. Simplified20.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1100:\\ \;\;\;\;re\\ \mathbf{elif}\;im \leq 1.75 \cdot 10^{+236}:\\ \;\;\;\;\frac{0.25}{re \cdot re}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot -4\right)\\ \end{array} \]

Alternative 13: 48.2% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 30.0% accurate, 43.8× speedup?

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

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

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


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

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

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

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

    if 2.8e6 < 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 2.7%

      \[\leadsto \color{blue}{\sin re} \]
    5. Applied egg-rr2.0%

      \[\leadsto \color{blue}{-2 - -2 \cdot \cos \left(-2 \cdot re\right)} \]
    6. Taylor expanded in re around 0 15.8%

      \[\leadsto \color{blue}{-4 \cdot {re}^{2}} \]
    7. Step-by-step derivation
      1. unpow215.8%

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

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -4\right)} \]
    8. Simplified15.8%

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

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

Alternative 15: 4.4% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin re + 0.5 \cdot \color{blue}{-4} \]
  7. Taylor expanded in re around 0 4.3%

    \[\leadsto \color{blue}{-2} \]
  8. Final simplification4.3%

    \[\leadsto -2 \]

Alternative 16: 27.0% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto re \]

Reproduce

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