math.sin on complex, real part

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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. sub0-neg100.0%

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} + e^{im}\right) \cdot 0.75\\ \mathbf{if}\;im \leq 78:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+144}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (+ (exp (- im)) (exp im)) 0.75)))
   (if (<= im 78.0)
     (* (sin re) (fma im (* 0.5 im) 1.0))
     (if (<= im 1.5e+114)
       t_0
       (if (<= im 2.3e+144)
         (log1p (expm1 re))
         (if (<= im 1.35e+154) t_0 (* (* 0.5 (sin re)) (* im im))))))))
double code(double re, double im) {
	double t_0 = (exp(-im) + exp(im)) * 0.75;
	double tmp;
	if (im <= 78.0) {
		tmp = sin(re) * fma(im, (0.5 * im), 1.0);
	} else if (im <= 1.5e+114) {
		tmp = t_0;
	} else if (im <= 2.3e+144) {
		tmp = log1p(expm1(re));
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = (0.5 * sin(re)) * (im * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) + exp(im)) * 0.75)
	tmp = 0.0
	if (im <= 78.0)
		tmp = Float64(sin(re) * fma(im, Float64(0.5 * im), 1.0));
	elseif (im <= 1.5e+114)
		tmp = t_0;
	elseif (im <= 2.3e+144)
		tmp = log1p(expm1(re));
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * 0.75), $MachinePrecision]}, If[LessEqual[im, 78.0], N[(N[Sin[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.5e+114], t$95$0, If[LessEqual[im, 2.3e+144], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-im} + e^{im}\right) \cdot 0.75\\
\mathbf{if}\;im \leq 78:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\

\mathbf{elif}\;im \leq 1.5 \cdot 10^{+114}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

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

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


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

    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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot \left(0.5 \cdot im\right)} + 1\right) \cdot \sin re \]
      7. fma-udef82.9%

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

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

    if 78 < im < 1.5e114 or 2.3000000000000001e144 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

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

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

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

    if 1.5e114 < im < 2.3000000000000001e144

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 78:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+114}:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+144}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot 0.75\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 3: 84.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 9e-5)
   (* (sin re) (fma im (* 0.5 im) 1.0))
   (if (<= im 2.3e+151)
     (* (+ (exp (- im)) (exp im)) (* 0.5 re))
     (* (* 0.5 (sin re)) (* im im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 9e-5) {
		tmp = sin(re) * fma(im, (0.5 * im), 1.0);
	} else if (im <= 2.3e+151) {
		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 <= 9e-5)
		tmp = Float64(sin(re) * fma(im, Float64(0.5 * im), 1.0));
	elseif (im <= 2.3e+151)
		tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 9e-5], N[(N[Sin[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.3e+151], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.00000000000000057e-5 < im < 2.3000000000000001e151

    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. sub0-neg100.0%

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

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

    if 2.3000000000000001e151 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

Alternative 4: 77.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 155000000:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+113}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 155000000.0)
   (* (sin re) (fma im (* 0.5 im) 1.0))
   (if (<= im 1.02e+113)
     (+ re (* (* im im) (* 0.5 (+ re (* (pow re 3.0) -0.16666666666666666)))))
     (if (<= im 2.3e+151) (log1p (expm1 re)) (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 155000000.0) {
		tmp = sin(re) * fma(im, (0.5 * im), 1.0);
	} else if (im <= 1.02e+113) {
		tmp = re + ((im * im) * (0.5 * (re + (pow(re, 3.0) * -0.16666666666666666))));
	} else if (im <= 2.3e+151) {
		tmp = log1p(expm1(re));
	} else {
		tmp = (0.5 * sin(re)) * (im * im);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 155000000.0)
		tmp = Float64(sin(re) * fma(im, Float64(0.5 * im), 1.0));
	elseif (im <= 1.02e+113)
		tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)))));
	elseif (im <= 2.3e+151)
		tmp = log1p(expm1(re));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 155000000.0], N[(N[Sin[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+113], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.3e+151], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.02 \cdot 10^{+113}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

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


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

    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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55e8 < im < 1.02000000000000002e113

    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. sub0-neg100.0%

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

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

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

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

      \[\leadsto re + \left(0.5 \cdot \color{blue}{\left(re + -0.16666666666666666 \cdot {re}^{3}\right)}\right) \cdot \left(im \cdot im\right) \]
    8. Simplified37.0%

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

    if 1.02000000000000002e113 < im < 2.3000000000000001e151

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 2.3000000000000001e151 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 155000000:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+113}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 5: 64.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+113}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 9e-5)
   (sin re)
   (if (<= im 4.3e+113)
     (+ re (* (* im im) (* 0.5 (+ re (* (pow re 3.0) -0.16666666666666666)))))
     (if (<= im 2.3e+151) (log1p (expm1 re)) (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 9e-5) {
		tmp = sin(re);
	} else if (im <= 4.3e+113) {
		tmp = re + ((im * im) * (0.5 * (re + (pow(re, 3.0) * -0.16666666666666666))));
	} else if (im <= 2.3e+151) {
		tmp = log1p(expm1(re));
	} else {
		tmp = (0.5 * sin(re)) * (im * im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 9e-5) {
		tmp = Math.sin(re);
	} else if (im <= 4.3e+113) {
		tmp = re + ((im * im) * (0.5 * (re + (Math.pow(re, 3.0) * -0.16666666666666666))));
	} else if (im <= 2.3e+151) {
		tmp = Math.log1p(Math.expm1(re));
	} else {
		tmp = (0.5 * Math.sin(re)) * (im * im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 9e-5:
		tmp = math.sin(re)
	elif im <= 4.3e+113:
		tmp = re + ((im * im) * (0.5 * (re + (math.pow(re, 3.0) * -0.16666666666666666))))
	elif im <= 2.3e+151:
		tmp = math.log1p(math.expm1(re))
	else:
		tmp = (0.5 * math.sin(re)) * (im * im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 9e-5)
		tmp = sin(re);
	elseif (im <= 4.3e+113)
		tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)))));
	elseif (im <= 2.3e+151)
		tmp = log1p(expm1(re));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 9e-5], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.3e+113], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.3e+151], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 4.3 \cdot 10^{+113}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 9.00000000000000057e-5

    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. sub0-neg100.0%

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

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

    if 9.00000000000000057e-5 < im < 4.3000000000000003e113

    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. sub0-neg100.0%

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

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

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

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

      \[\leadsto re + \left(0.5 \cdot \color{blue}{\left(re + -0.16666666666666666 \cdot {re}^{3}\right)}\right) \cdot \left(im \cdot im\right) \]
    8. Simplified36.7%

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

    if 4.3000000000000003e113 < im < 2.3000000000000001e151

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 2.3000000000000001e151 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+113}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 6: 64.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+112}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 9e-5)
   (sin re)
   (if (<= im 5e+112)
     (+ re (* (* im im) (* 0.5 (+ re (* (pow re 3.0) -0.16666666666666666)))))
     (if (<= im 2.3e+151)
       (* im (* re (* 0.5 im)))
       (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 9e-5) {
		tmp = sin(re);
	} else if (im <= 5e+112) {
		tmp = re + ((im * im) * (0.5 * (re + (pow(re, 3.0) * -0.16666666666666666))));
	} else if (im <= 2.3e+151) {
		tmp = im * (re * (0.5 * im));
	} 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 <= 9d-5) then
        tmp = sin(re)
    else if (im <= 5d+112) then
        tmp = re + ((im * im) * (0.5d0 * (re + ((re ** 3.0d0) * (-0.16666666666666666d0)))))
    else if (im <= 2.3d+151) then
        tmp = im * (re * (0.5d0 * im))
    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 <= 9e-5) {
		tmp = Math.sin(re);
	} else if (im <= 5e+112) {
		tmp = re + ((im * im) * (0.5 * (re + (Math.pow(re, 3.0) * -0.16666666666666666))));
	} else if (im <= 2.3e+151) {
		tmp = im * (re * (0.5 * im));
	} else {
		tmp = (0.5 * Math.sin(re)) * (im * im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 9e-5:
		tmp = math.sin(re)
	elif im <= 5e+112:
		tmp = re + ((im * im) * (0.5 * (re + (math.pow(re, 3.0) * -0.16666666666666666))))
	elif im <= 2.3e+151:
		tmp = im * (re * (0.5 * im))
	else:
		tmp = (0.5 * math.sin(re)) * (im * im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 9e-5)
		tmp = sin(re);
	elseif (im <= 5e+112)
		tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)))));
	elseif (im <= 2.3e+151)
		tmp = Float64(im * Float64(re * Float64(0.5 * im)));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 9e-5)
		tmp = sin(re);
	elseif (im <= 5e+112)
		tmp = re + ((im * im) * (0.5 * (re + ((re ^ 3.0) * -0.16666666666666666))));
	elseif (im <= 2.3e+151)
		tmp = im * (re * (0.5 * im));
	else
		tmp = (0.5 * sin(re)) * (im * im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 9e-5], N[Sin[re], $MachinePrecision], If[LessEqual[im, 5e+112], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.3e+151], N[(im * N[(re * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 5 \cdot 10^{+112}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 9.00000000000000057e-5

    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. sub0-neg100.0%

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

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

    if 9.00000000000000057e-5 < im < 5e112

    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. sub0-neg100.0%

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

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

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

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

      \[\leadsto re + \left(0.5 \cdot \color{blue}{\left(re + -0.16666666666666666 \cdot {re}^{3}\right)}\right) \cdot \left(im \cdot im\right) \]
    8. Simplified38.0%

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

    if 5e112 < im < 2.3000000000000001e151

    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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(0.5 \cdot im\right)} \cdot re\right) \]
    12. Simplified40.7%

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

    if 2.3000000000000001e151 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+112}:\\ \;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + {re}^{3} \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 7: 64.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 220000000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+96}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 220000000000.0)
   (sin re)
   (if (<= im 8.2e+96)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (if (<= im 2.3e+151)
       (* im (* re (* 0.5 im)))
       (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 220000000000.0) {
		tmp = sin(re);
	} else if (im <= 8.2e+96) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else if (im <= 2.3e+151) {
		tmp = im * (re * (0.5 * im));
	} 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 <= 220000000000.0d0) then
        tmp = sin(re)
    else if (im <= 8.2d+96) then
        tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
    else if (im <= 2.3d+151) then
        tmp = im * (re * (0.5d0 * im))
    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 <= 220000000000.0) {
		tmp = Math.sin(re);
	} else if (im <= 8.2e+96) {
		tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
	} else if (im <= 2.3e+151) {
		tmp = im * (re * (0.5 * im));
	} else {
		tmp = (0.5 * Math.sin(re)) * (im * im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 220000000000.0:
		tmp = math.sin(re)
	elif im <= 8.2e+96:
		tmp = re + (math.pow(re, 3.0) * -0.16666666666666666)
	elif im <= 2.3e+151:
		tmp = im * (re * (0.5 * im))
	else:
		tmp = (0.5 * math.sin(re)) * (im * im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 220000000000.0)
		tmp = sin(re);
	elseif (im <= 8.2e+96)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	elseif (im <= 2.3e+151)
		tmp = Float64(im * Float64(re * Float64(0.5 * im)));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 220000000000.0)
		tmp = sin(re);
	elseif (im <= 8.2e+96)
		tmp = re + ((re ^ 3.0) * -0.16666666666666666);
	elseif (im <= 2.3e+151)
		tmp = im * (re * (0.5 * im));
	else
		tmp = (0.5 * sin(re)) * (im * im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 220000000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.2e+96], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.3e+151], N[(im * N[(re * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\

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


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

    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. sub0-neg100.0%

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

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

    if 2.2e11 < im < 8.19999999999999996e96

    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. sub0-neg100.0%

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

      \[\leadsto \color{blue}{re + -0.16666666666666666 \cdot {re}^{3}} \]
    6. Simplified39.0%

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

    if 8.19999999999999996e96 < im < 2.3000000000000001e151

    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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(0.5 \cdot im\right)} \cdot re\right) \]
    12. Simplified31.4%

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

    if 2.3000000000000001e151 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 220000000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+96}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+151}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 8: 61.1% accurate, 2.8× speedup?

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

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

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

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


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

    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. sub0-neg100.0%

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

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

    if 1.9e11 < im < 5.79999999999999974e97

    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. sub0-neg100.0%

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

      \[\leadsto \color{blue}{re + -0.16666666666666666 \cdot {re}^{3}} \]
    6. Simplified39.0%

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

    if 5.79999999999999974e97 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 190000000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+97}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 9: 61.8% accurate, 2.9× speedup?

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

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

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

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


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

    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. sub0-neg100.0%

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

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

    if 1.55e8 < im < 1.6e104

    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. sub0-neg100.0%

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

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

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

    if 1.6e104 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 60.5% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\sin 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 6.2e-5) (sin re) (* re (+ 1.0 (* 0.5 (* im im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 6.2e-5) {
		tmp = sin(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 <= 6.2d-5) then
        tmp = sin(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 <= 6.2e-5) {
		tmp = Math.sin(re);
	} else {
		tmp = re * (1.0 + (0.5 * (im * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 6.2e-5:
		tmp = math.sin(re)
	else:
		tmp = re * (1.0 + (0.5 * (im * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 6.2e-5)
		tmp = sin(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 <= 6.2e-5)
		tmp = sin(re);
	else
		tmp = re * (1.0 + (0.5 * (im * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 6.2e-5], N[Sin[re], $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 6.2 \cdot 10^{-5}:\\
\;\;\;\;\sin 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 2 regimes
  2. if im < 6.20000000000000027e-5

    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. sub0-neg100.0%

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

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

    if 6.20000000000000027e-5 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 47.6% accurate, 27.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -3.4 \cdot 10^{+121}:\\ \;\;\;\;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 (<= re -3.4e+121) (* re re) (* re (+ 1.0 (* 0.5 (* im im))))))
double code(double re, double im) {
	double tmp;
	if (re <= -3.4e+121) {
		tmp = 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 (re <= (-3.4d+121)) then
        tmp = 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 (re <= -3.4e+121) {
		tmp = re * re;
	} else {
		tmp = re * (1.0 + (0.5 * (im * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -3.4e+121:
		tmp = re * re
	else:
		tmp = re * (1.0 + (0.5 * (im * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -3.4e+121)
		tmp = 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 (re <= -3.4e+121)
		tmp = re * re;
	else
		tmp = re * (1.0 + (0.5 * (im * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -3.4e+121], N[(re * re), $MachinePrecision], N[(re * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.4 \cdot 10^{+121}:\\
\;\;\;\;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 2 regimes
  2. if re < -3.4000000000000001e121

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{\sqrt[3]{re}} \]
    6. Applied egg-rr27.0%

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

    if -3.4000000000000001e121 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 33.6% accurate, 34.1× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 1.44999999999999996 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(0.5 \cdot im\right)} \cdot re\right) \]
    12. Simplified32.0%

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

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

Alternative 13: 36.4% accurate, 34.1× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 1.44999999999999996 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 29.0% accurate, 61.0× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 2.35e19 < 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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{\sqrt[3]{re}} \]
    6. Applied egg-rr12.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.35 \cdot 10^{+19}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot re\\ \end{array} \]

Alternative 15: 26.3% 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. sub0-neg100.0%

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

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

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

    \[\leadsto re \]

Reproduce

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