math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 6.4s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

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

\\
\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot \sin re\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. Final simplification100.0%

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

Alternative 2: 84.3% accurate, 1.5× speedup?

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

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

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

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


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

    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. Taylor expanded in im around 0 82.4%

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

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

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

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

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

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

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

    if 5600 < 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. Taylor expanded in re around 0 72.0%

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

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

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

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

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

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

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

Alternative 3: 64.5% accurate, 1.5× speedup?

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

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

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

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


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

    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. Taylor expanded in im around 0 62.8%

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

    if 2.3e8 < 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. Taylor expanded in re around 0 73.9%

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

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

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-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. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

Alternative 4: 77.8% accurate, 1.5× speedup?

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

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

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

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


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

    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. Taylor expanded in im around 0 81.6%

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

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

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

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

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

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

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

    if 2.3e8 < 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. Taylor expanded in re around 0 73.9%

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

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

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-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. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

Alternative 5: 61.8% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+144}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\


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

    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. Taylor expanded in im around 0 62.8%

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

    if 2.3e8 < im < 1.40000000000000003e144

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

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

    if 1.40000000000000003e144 < 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. Taylor expanded in im around 0 97.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(\color{blue}{im \cdot im} + 2\right)\right) \]
      3. fma-udef74.2%

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

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

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

Alternative 6: 61.8% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 1.54 \cdot 10^{+144}:\\
\;\;\;\;{re}^{-4}\\

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


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

    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. Taylor expanded in im around 0 62.8%

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

    if 2.3e8 < im < 1.54000000000000005e144

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

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

    if 1.54000000000000005e144 < 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. Taylor expanded in im around 0 97.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(\color{blue}{im \cdot im} + 2\right)\right) \]
      3. fma-udef74.2%

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \mathsf{fma}\left(im, im, 2\right)\right)} \]
    8. Taylor expanded in im around inf 74.2%

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

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

Alternative 7: 55.0% accurate, 3.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\


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

    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. Taylor expanded in im around 0 62.8%

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

    if 2.3e8 < 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. Taylor expanded in re around 0 73.6%

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

      \[\leadsto \color{blue}{{re}^{-4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification52.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 230000000:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;{re}^{-4}\\ \end{array} \]

Alternative 8: 50.5% accurate, 3.1× speedup?

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

\\
\sin 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. Taylor expanded in im around 0 50.3%

    \[\leadsto \color{blue}{\sin re} \]
  5. Final simplification50.3%

    \[\leadsto \sin re \]

Alternative 9: 27.3% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 8.6 \cdot 10^{-17}:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 8.60000000000000046e-17

    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. Taylor expanded in re around 0 73.7%

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

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

    if 8.60000000000000046e-17 < re

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-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. Taylor expanded in re around 0 27.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 8.6 \cdot 10^{-17}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{re}{re + \left(re - re\right)}\\ \end{array} \]

Alternative 10: 27.8% accurate, 100.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 650000:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= re 650000.0) re -1.0))
double code(double re, double im) {
	double tmp;
	if (re <= 650000.0) {
		tmp = re;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 650000.0d0) then
        tmp = re
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 650000.0) {
		tmp = re;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 650000.0:
		tmp = re
	else:
		tmp = -1.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 650000.0)
		tmp = re;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 650000.0)
		tmp = re;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 650000.0], re, -1.0]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 6.5e5

    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. Taylor expanded in re around 0 74.1%

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

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

    if 6.5e5 < re

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-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. Taylor expanded in im around 0 78.7%

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

      \[\leadsto \sin re + 0.5 \cdot \color{blue}{-2} \]
    6. Taylor expanded in re around 0 5.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 650000:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 11: 4.6% accurate, 309.0× speedup?

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

\\
-1
\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. Taylor expanded in im around 0 76.9%

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

    \[\leadsto \sin re + 0.5 \cdot \color{blue}{-2} \]
  6. Taylor expanded in re around 0 4.4%

    \[\leadsto \color{blue}{-1} \]
  7. Final simplification4.4%

    \[\leadsto -1 \]

Reproduce

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