math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.4s
Alternatives: 9
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 9 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-rgt-in100.0%

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

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

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

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

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

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

Alternative 2: 81.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{if}\;im \leq 640:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+63}:\\ \;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re + re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (fma im im 2.0))))
   (if (<= im 640.0)
     t_0
     (if (<= im 3.4e+63)
       (pow (* (sin re) -2.0) -2.0)
       (if (<= im 1.35e+154)
         (+ re (* re (* 0.041666666666666664 (pow im 4.0))))
         t_0)))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * fma(im, im, 2.0);
	double tmp;
	if (im <= 640.0) {
		tmp = t_0;
	} else if (im <= 3.4e+63) {
		tmp = pow((sin(re) * -2.0), -2.0);
	} else if (im <= 1.35e+154) {
		tmp = re + (re * (0.041666666666666664 * pow(im, 4.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0))
	tmp = 0.0
	if (im <= 640.0)
		tmp = t_0;
	elseif (im <= 3.4e+63)
		tmp = Float64(sin(re) * -2.0) ^ -2.0;
	elseif (im <= 1.35e+154)
		tmp = Float64(re + Float64(re * Float64(0.041666666666666664 * (im ^ 4.0))));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 640.0], t$95$0, If[LessEqual[im, 3.4e+63], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(re + N[(re * N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 3.4 \cdot 10^{+63}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 640 < im < 3.3999999999999999e63

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-\left(-e^{im}\right)\right)\right) \]
      6. 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. Add Preprocessing
    5. Applied egg-rr34.1%

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]

    if 3.3999999999999999e63 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re + \color{blue}{re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)} \]
    12. Simplified76.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 640:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+63}:\\ \;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re + re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.022 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 0.022) (not (<= im 1.35e+154)))
   (* (* 0.5 (sin re)) (fma im im 2.0))
   (* (* 0.5 re) (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if ((im <= 0.022) || !(im <= 1.35e+154)) {
		tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
	} else {
		tmp = (0.5 * re) * (exp(-im) + exp(im));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if ((im <= 0.022) || !(im <= 1.35e+154))
		tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0));
	else
		tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im)));
	end
	return tmp
end
code[re_, im_] := If[Or[LessEqual[im, 0.022], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.022 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 0.021999999999999999 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 0.021999999999999999 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.022 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 65.2% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 9.5 \cdot 10^{+63}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 1050 < im < 9.5000000000000003e63

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-\left(-e^{im}\right)\right)\right) \]
      6. 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. Add Preprocessing
    5. Applied egg-rr34.1%

      \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]

    if 9.5000000000000003e63 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    7. Taylor expanded in im around 0 70.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)} \]
    8. Step-by-step derivation
      1. +-commutative70.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1050:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.5 \cdot 10^{+63}:\\ \;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;re + re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 65.2% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;im \leq 8.2 \cdot 10^{+61}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 720 < im < 8.19999999999999944e61

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-\left(-e^{im}\right)\right)\right) \]
      6. 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. Add Preprocessing
    5. Applied egg-rr34.1%

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

      \[\leadsto \color{blue}{\frac{0.25}{{re}^{2}}} \]

    if 8.19999999999999944e61 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    7. Taylor expanded in im around 0 70.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)} \]
    8. Step-by-step derivation
      1. +-commutative70.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 720:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{0.25}{{re}^{2}}\\ \mathbf{else}:\\ \;\;\;\;re + re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.5% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+98}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 520 < im < 6.4999999999999999e98

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-\left(-e^{im}\right)\right)\right) \]
      6. 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. Add Preprocessing
    5. Applied egg-rr21.6%

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

      \[\leadsto \color{blue}{\frac{0.25}{{re}^{2}}} \]

    if 6.4999999999999999e98 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \left(1 + {\left(\color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)} \cdot \sqrt{0.5}\right)}^{2}\right) \]
      7. add-sqr-sqrt60.8%

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

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

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

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

        \[\leadsto re \cdot \left(1 + \left(\sqrt{0.5} \cdot im\right) \cdot \color{blue}{\left(\sqrt{0.5} \cdot im\right)}\right) \]
      4. swap-sqr60.8%

        \[\leadsto re \cdot \left(1 + \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \left(im \cdot im\right)}\right) \]
      5. rem-square-sqrt60.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 520:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+98}:\\ \;\;\;\;\frac{0.25}{{re}^{2}}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.2% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 0.112000000000000002 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \left(1 + {\left(\sqrt{\color{blue}{im \cdot im}} \cdot \sqrt{0.5}\right)}^{2}\right) \]
      6. sqrt-prod47.9%

        \[\leadsto re \cdot \left(1 + {\left(\color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)} \cdot \sqrt{0.5}\right)}^{2}\right) \]
      7. add-sqr-sqrt47.9%

        \[\leadsto re \cdot \left(1 + {\left(\color{blue}{im} \cdot \sqrt{0.5}\right)}^{2}\right) \]
    9. Applied egg-rr47.9%

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

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

        \[\leadsto re \cdot \left(1 + \color{blue}{\left(\sqrt{0.5} \cdot im\right)} \cdot \left(im \cdot \sqrt{0.5}\right)\right) \]
      3. *-commutative47.9%

        \[\leadsto re \cdot \left(1 + \left(\sqrt{0.5} \cdot im\right) \cdot \color{blue}{\left(\sqrt{0.5} \cdot im\right)}\right) \]
      4. swap-sqr47.9%

        \[\leadsto re \cdot \left(1 + \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \left(im \cdot im\right)}\right) \]
      5. rem-square-sqrt47.9%

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

        \[\leadsto re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im\right) \cdot im}\right) \]
    11. Applied egg-rr47.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.112:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 47.5% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto re \cdot \left(1 + {\left(\sqrt{\color{blue}{im \cdot im}} \cdot \sqrt{0.5}\right)}^{2}\right) \]
    6. sqrt-prod25.6%

      \[\leadsto re \cdot \left(1 + {\left(\color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)} \cdot \sqrt{0.5}\right)}^{2}\right) \]
    7. add-sqr-sqrt48.7%

      \[\leadsto re \cdot \left(1 + {\left(\color{blue}{im} \cdot \sqrt{0.5}\right)}^{2}\right) \]
  9. Applied egg-rr48.7%

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

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

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

      \[\leadsto re \cdot \left(1 + \left(\sqrt{0.5} \cdot im\right) \cdot \color{blue}{\left(\sqrt{0.5} \cdot im\right)}\right) \]
    4. swap-sqr48.7%

      \[\leadsto re \cdot \left(1 + \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right) \cdot \left(im \cdot im\right)}\right) \]
    5. rem-square-sqrt48.7%

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

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

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

    \[\leadsto re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right) \]
  13. Add Preprocessing

Alternative 9: 25.9% 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-rgt-in100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  9. Final simplification27.7%

    \[\leadsto re \]
  10. Add Preprocessing

Reproduce

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