math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.5s
Alternatives: 16
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 2: 91.8% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 170000000:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.7e8 < im < 8.60000000000000001e74

    1. Initial program 100.0%

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

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

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

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

    if 8.60000000000000001e74 < im

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto 0.041666666666666664 \cdot \color{blue}{\left({im}^{4} \cdot \sin re\right)} \]
    8. Simplified98.2%

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

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

Alternative 3: 86.0% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.7e8 < im < 8.60000000000000001e74

    1. Initial program 100.0%

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

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

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

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

    if 8.60000000000000001e74 < im

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto 0.041666666666666664 \cdot \color{blue}{\left({im}^{4} \cdot \sin re\right)} \]
    8. Simplified98.2%

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

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

Alternative 4: 83.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 580:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\ \;\;\;\;0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 580.0)
   (* (* 0.5 (sin re)) (+ 2.0 (* im im)))
   (if (<= im 1.16e+77)
     (+
      0.08333333333333333
      (+ (/ 0.25 (* re re)) (* (* re re) 0.016666666666666666)))
     (* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 580.0) {
		tmp = (0.5 * sin(re)) * (2.0 + (im * im));
	} else if (im <= 1.16e+77) {
		tmp = 0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666));
	} else {
		tmp = 0.041666666666666664 * (sin(re) * 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 <= 580.0d0) then
        tmp = (0.5d0 * sin(re)) * (2.0d0 + (im * im))
    else if (im <= 1.16d+77) then
        tmp = 0.08333333333333333d0 + ((0.25d0 / (re * re)) + ((re * re) * 0.016666666666666666d0))
    else
        tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 580.0) {
		tmp = (0.5 * Math.sin(re)) * (2.0 + (im * im));
	} else if (im <= 1.16e+77) {
		tmp = 0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666));
	} else {
		tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 580.0:
		tmp = (0.5 * math.sin(re)) * (2.0 + (im * im))
	elif im <= 1.16e+77:
		tmp = 0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666))
	else:
		tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 580.0)
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.0 + Float64(im * im)));
	elseif (im <= 1.16e+77)
		tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / Float64(re * re)) + Float64(Float64(re * re) * 0.016666666666666666)));
	else
		tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 580.0)
		tmp = (0.5 * sin(re)) * (2.0 + (im * im));
	elseif (im <= 1.16e+77)
		tmp = 0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666));
	else
		tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 580.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.16e+77], N[(0.08333333333333333 + N[(N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\
\;\;\;\;0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 580 < im < 1.1600000000000001e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \color{blue}{\left(re \cdot re\right)} \cdot 0.016666666666666666\right) \]
    7. Simplified38.8%

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

    if 1.1600000000000001e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 580:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\ \;\;\;\;0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \]

Alternative 5: 85.1% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 120 < im < 1.1600000000000001e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \color{blue}{1}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    7. Simplified56.3%

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

    if 1.1600000000000001e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

Alternative 6: 81.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ t_1 := 2 + im \cdot im\\ \mathbf{if}\;im \leq 170000000:\\ \;\;\;\;t_0 \cdot t_1\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+58}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+153}:\\ \;\;\;\;\left(t_1 + {im}^{4} \cdot 0.08333333333333333\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))) (t_1 (+ 2.0 (* im im))))
   (if (<= im 170000000.0)
     (* t_0 t_1)
     (if (<= im 4.3e+58)
       (pow re -512.0)
       (if (<= im 2.1e+153)
         (* (+ t_1 (* (pow im 4.0) 0.08333333333333333)) (* 0.5 re))
         (* t_0 (* im im)))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double t_1 = 2.0 + (im * im);
	double tmp;
	if (im <= 170000000.0) {
		tmp = t_0 * t_1;
	} else if (im <= 4.3e+58) {
		tmp = pow(re, -512.0);
	} else if (im <= 2.1e+153) {
		tmp = (t_1 + (pow(im, 4.0) * 0.08333333333333333)) * (0.5 * re);
	} else {
		tmp = t_0 * (im * im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * sin(re)
    t_1 = 2.0d0 + (im * im)
    if (im <= 170000000.0d0) then
        tmp = t_0 * t_1
    else if (im <= 4.3d+58) then
        tmp = re ** (-512.0d0)
    else if (im <= 2.1d+153) then
        tmp = (t_1 + ((im ** 4.0d0) * 0.08333333333333333d0)) * (0.5d0 * re)
    else
        tmp = t_0 * (im * im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * Math.sin(re);
	double t_1 = 2.0 + (im * im);
	double tmp;
	if (im <= 170000000.0) {
		tmp = t_0 * t_1;
	} else if (im <= 4.3e+58) {
		tmp = Math.pow(re, -512.0);
	} else if (im <= 2.1e+153) {
		tmp = (t_1 + (Math.pow(im, 4.0) * 0.08333333333333333)) * (0.5 * re);
	} else {
		tmp = t_0 * (im * im);
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * math.sin(re)
	t_1 = 2.0 + (im * im)
	tmp = 0
	if im <= 170000000.0:
		tmp = t_0 * t_1
	elif im <= 4.3e+58:
		tmp = math.pow(re, -512.0)
	elif im <= 2.1e+153:
		tmp = (t_1 + (math.pow(im, 4.0) * 0.08333333333333333)) * (0.5 * re)
	else:
		tmp = t_0 * (im * im)
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	t_1 = Float64(2.0 + Float64(im * im))
	tmp = 0.0
	if (im <= 170000000.0)
		tmp = Float64(t_0 * t_1);
	elseif (im <= 4.3e+58)
		tmp = re ^ -512.0;
	elseif (im <= 2.1e+153)
		tmp = Float64(Float64(t_1 + Float64((im ^ 4.0) * 0.08333333333333333)) * Float64(0.5 * re));
	else
		tmp = Float64(t_0 * Float64(im * im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * sin(re);
	t_1 = 2.0 + (im * im);
	tmp = 0.0;
	if (im <= 170000000.0)
		tmp = t_0 * t_1;
	elseif (im <= 4.3e+58)
		tmp = re ^ -512.0;
	elseif (im <= 2.1e+153)
		tmp = (t_1 + ((im ^ 4.0) * 0.08333333333333333)) * (0.5 * re);
	else
		tmp = t_0 * (im * im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 170000000.0], N[(t$95$0 * t$95$1), $MachinePrecision], If[LessEqual[im, 4.3e+58], N[Power[re, -512.0], $MachinePrecision], If[LessEqual[im, 2.1e+153], N[(N[(t$95$1 + N[(N[Power[im, 4.0], $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := 2 + im \cdot im\\
\mathbf{if}\;im \leq 170000000:\\
\;\;\;\;t_0 \cdot t_1\\

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

\mathbf{elif}\;im \leq 2.1 \cdot 10^{+153}:\\
\;\;\;\;\left(t_1 + {im}^{4} \cdot 0.08333333333333333\right) \cdot \left(0.5 \cdot re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.7e8 < im < 4.29999999999999991e58

    1. Initial program 100.0%

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

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

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

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

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

    if 4.29999999999999991e58 < im < 2.10000000000000017e153

    1. Initial program 100.0%

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

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

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

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

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

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

    if 2.10000000000000017e153 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 170000000:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+58}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+153}:\\ \;\;\;\;\left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 7: 66.7% accurate, 2.7× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

    if 5.4e8 < im < 2.95000000000000006e57

    1. Initial program 100.0%

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

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

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

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

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

    if 2.95000000000000006e57 < im < 4.0000000000000002e222

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 4.0000000000000002e222 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 540000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.95 \cdot 10^{+57}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 4 \cdot 10^{+222}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(\sin re \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 69.0% accurate, 2.7× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

    if 1.7e8 < im < 5.7000000000000002e56

    1. Initial program 100.0%

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

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

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

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

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

    if 5.7000000000000002e56 < im < 2.10000000000000017e153

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 2.10000000000000017e153 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 170000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5.7 \cdot 10^{+56}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+153}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 9: 81.7% accurate, 2.7× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.7e8 < im < 1.14999999999999994e55

    1. Initial program 100.0%

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

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

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

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

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

    if 1.14999999999999994e55 < im < 2.10000000000000017e153

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 2.10000000000000017e153 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 170000000:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+55}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+153}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 10: 66.1% accurate, 2.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

    if 1.7e8 < im < 9.80000000000000037e58

    1. Initial program 100.0%

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

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

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

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

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

    if 9.80000000000000037e58 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 170000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+58}:\\ \;\;\;\;{re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \end{array} \]

Alternative 11: 63.4% accurate, 3.0× speedup?

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

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

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+148}:\\
\;\;\;\;0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

    if 760 < im < 6.49999999999999947e148

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 6.49999999999999947e148 < im

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 760:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+148}:\\ \;\;\;\;0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \]

Alternative 12: 37.6% accurate, 27.8× speedup?

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

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

\mathbf{elif}\;im \leq 2.25 \cdot 10^{+105}:\\
\;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 400 < im < 2.2500000000000001e105

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \color{blue}{\left(re \cdot re\right)} \cdot 0.016666666666666666\right) \]
    7. Simplified36.8%

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

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

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

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

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

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

    if 2.2500000000000001e105 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 48.2% accurate, 27.9× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \color{blue}{\left(re \cdot re\right)} \cdot 0.016666666666666666\right) \]
    7. Simplified33.5%

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

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

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

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

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

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

    if -3.4500000000000001e159 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 14: 37.3% accurate, 34.1× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.7e8 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 29.5% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 980 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 980:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{re \cdot re}\\ \end{array} \]

Alternative 16: 26.7% accurate, 309.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto re \]

Reproduce

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