math.sin on complex, real part

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 17 < im < 1.1999999999999999e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1999999999999999e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{{im}^{2} \cdot {im}^{2}}} \cdot \left(0.5 \cdot \sin re\right) \]
      3. pow-prod-up100.0%

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

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

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

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

Alternative 3: 85.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 17:\\ \;\;\;\;t_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.45 \cdot 10^{+151}:\\ \;\;\;\;\left(e^{-im} + e^{im}\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))))
   (if (<= im 17.0)
     (* t_0 (fma im im 2.0))
     (if (<= im 1.45e+151)
       (* (+ (exp (- im)) (exp im)) (* 0.5 re))
       (* t_0 (* im im))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if (im <= 17.0) {
		tmp = t_0 * fma(im, im, 2.0);
	} else if (im <= 1.45e+151) {
		tmp = (exp(-im) + exp(im)) * (0.5 * re);
	} else {
		tmp = t_0 * (im * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (im <= 17.0)
		tmp = Float64(t_0 * fma(im, im, 2.0));
	elseif (im <= 1.45e+151)
		tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re));
	else
		tmp = Float64(t_0 * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 17.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.45e+151], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $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\\
\mathbf{if}\;im \leq 17:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{elif}\;im \leq 1.45 \cdot 10^{+151}:\\
\;\;\;\;\left(e^{-im} + e^{im}\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 3 regimes
  2. if im < 17

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 17 < im < 1.45000000000000009e151

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000009e151 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.0% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 17 < im < 1.45000000000000009e151

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000009e151 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 4500000:\\ \;\;\;\;t_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re + re \cdot \left(re \cdot -0.16666666666666666\right)\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 4500000.0)
     (* t_0 (fma im im 2.0))
     (if (<= im 1.4e+154)
       (* (fma im im 2.0) (+ (* 0.5 re) (* re (* re -0.16666666666666666))))
       (* t_0 (* im im))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if (im <= 4500000.0) {
		tmp = t_0 * fma(im, im, 2.0);
	} else if (im <= 1.4e+154) {
		tmp = fma(im, im, 2.0) * ((0.5 * re) + (re * (re * -0.16666666666666666)));
	} else {
		tmp = t_0 * (im * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (im <= 4500000.0)
		tmp = Float64(t_0 * fma(im, im, 2.0));
	elseif (im <= 1.4e+154)
		tmp = Float64(fma(im, im, 2.0) * Float64(Float64(0.5 * re) + Float64(re * Float64(re * -0.16666666666666666))));
	else
		tmp = Float64(t_0 * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4500000.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.4e+154], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(0.5 * re), $MachinePrecision] + N[(re * N[(re * -0.16666666666666666), $MachinePrecision]), $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 4500000:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re + re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5e6 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative24.2%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative24.2%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified24.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr0.0%

      \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{e^{\log re + \log \left(re \cdot -0.16666666666666666\right)}}\right) \]
    10. Step-by-step derivation
      1. exp-sum0.0%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{e^{\log re} \cdot e^{\log \left(re \cdot -0.16666666666666666\right)}}\right) \]
      2. rem-exp-log13.9%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{re} \cdot e^{\log \left(re \cdot -0.16666666666666666\right)}\right) \]
      3. rem-exp-log28.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + re \cdot \color{blue}{\left(re \cdot -0.16666666666666666\right)}\right) \]
    11. Simplified28.3%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 66.0% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 400:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re + re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 400.0)
   (sin re)
   (if (<= im 1.4e+154)
     (* (fma im im 2.0) (+ (* 0.5 re) (* re (* re -0.16666666666666666))))
     (* (* 0.5 (sin re)) (* im im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 400.0) {
		tmp = sin(re);
	} else if (im <= 1.4e+154) {
		tmp = fma(im, im, 2.0) * ((0.5 * re) + (re * (re * -0.16666666666666666)));
	} else {
		tmp = (0.5 * sin(re)) * (im * im);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 400.0)
		tmp = sin(re);
	elseif (im <= 1.4e+154)
		tmp = Float64(fma(im, im, 2.0) * Float64(Float64(0.5 * re) + Float64(re * Float64(re * -0.16666666666666666))));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(im * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 400.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.4e+154], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(0.5 * re), $MachinePrecision] + N[(re * N[(re * -0.16666666666666666), $MachinePrecision]), $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 400:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re + re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 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. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 400 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified23.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr0.0%

      \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{e^{\log re + \log \left(re \cdot -0.16666666666666666\right)}}\right) \]
    10. Step-by-step derivation
      1. exp-sum0.0%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{e^{\log re} \cdot e^{\log \left(re \cdot -0.16666666666666666\right)}}\right) \]
      2. rem-exp-log13.4%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{re} \cdot e^{\log \left(re \cdot -0.16666666666666666\right)}\right) \]
      3. rem-exp-log27.2%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + re \cdot \color{blue}{\left(re \cdot -0.16666666666666666\right)}\right) \]
    11. Simplified27.2%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 65.2% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1e5 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified23.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr22.6%

      \[\leadsto \color{blue}{re + \left(-re \cdot -0.16666666666666666\right) \cdot \left(re \cdot -0.16666666666666666\right)} \]
    10. Step-by-step derivation
      1. *-commutative22.6%

        \[\leadsto re + \color{blue}{\left(re \cdot -0.16666666666666666\right) \cdot \left(-re \cdot -0.16666666666666666\right)} \]
      2. distribute-rgt-neg-in22.6%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \color{blue}{\left(re \cdot \left(--0.16666666666666666\right)\right)} \]
      3. metadata-eval22.6%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \left(re \cdot \color{blue}{0.16666666666666666}\right) \]
    11. Simplified22.6%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 65.6% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.2e14 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative24.2%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative24.2%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified24.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Taylor expanded in im around 0 23.4%

      \[\leadsto \color{blue}{2 \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-in23.4%

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

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

        \[\leadsto \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} + \left(0.5 \cdot re\right) \cdot 2 \]
      4. metadata-eval23.4%

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

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

        \[\leadsto {re}^{3} \cdot -0.16666666666666666 + \color{blue}{re \cdot \left(0.5 \cdot 2\right)} \]
      7. metadata-eval23.4%

        \[\leadsto {re}^{3} \cdot -0.16666666666666666 + re \cdot \color{blue}{1} \]
    11. Simplified23.4%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 62.1% accurate, 3.0× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9500 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative23.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified23.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr22.6%

      \[\leadsto \color{blue}{re + \left(-re \cdot -0.16666666666666666\right) \cdot \left(re \cdot -0.16666666666666666\right)} \]
    10. Step-by-step derivation
      1. *-commutative22.6%

        \[\leadsto re + \color{blue}{\left(re \cdot -0.16666666666666666\right) \cdot \left(-re \cdot -0.16666666666666666\right)} \]
      2. distribute-rgt-neg-in22.6%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \color{blue}{\left(re \cdot \left(--0.16666666666666666\right)\right)} \]
      3. metadata-eval22.6%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \left(re \cdot \color{blue}{0.16666666666666666}\right) \]
    11. Simplified22.6%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \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}{\mathsf{fma}\left(im, im, 2\right)} \]
    6. Taylor expanded in re around 0 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 48.5% accurate, 27.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 8.8 \cdot 10^{+133}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.8e133 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right)} \]
      5. +-commutative37.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative37.8%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative37.8%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr35.8%

      \[\leadsto \color{blue}{re + \left(-re \cdot -0.16666666666666666\right) \cdot \left(re \cdot -0.16666666666666666\right)} \]
    10. Step-by-step derivation
      1. *-commutative35.8%

        \[\leadsto re + \color{blue}{\left(re \cdot -0.16666666666666666\right) \cdot \left(-re \cdot -0.16666666666666666\right)} \]
      2. distribute-rgt-neg-in35.8%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \color{blue}{\left(re \cdot \left(--0.16666666666666666\right)\right)} \]
      3. metadata-eval35.8%

        \[\leadsto re + \left(re \cdot -0.16666666666666666\right) \cdot \left(re \cdot \color{blue}{0.16666666666666666}\right) \]
    11. Simplified35.8%

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

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

Alternative 11: 30.1% accurate, 34.1× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e7 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{0.25}{{re}^{2}}} \cdot \sqrt{\frac{0.25}{{re}^{2}}}} \]
      2. sqrt-div17.0%

        \[\leadsto \color{blue}{\frac{\sqrt{0.25}}{\sqrt{{re}^{2}}}} \cdot \sqrt{\frac{0.25}{{re}^{2}}} \]
      3. metadata-eval17.0%

        \[\leadsto \frac{\color{blue}{0.5}}{\sqrt{{re}^{2}}} \cdot \sqrt{\frac{0.25}{{re}^{2}}} \]
      4. unpow217.0%

        \[\leadsto \frac{0.5}{\sqrt{\color{blue}{re \cdot re}}} \cdot \sqrt{\frac{0.25}{{re}^{2}}} \]
      5. sqrt-prod16.6%

        \[\leadsto \frac{0.5}{\color{blue}{\sqrt{re} \cdot \sqrt{re}}} \cdot \sqrt{\frac{0.25}{{re}^{2}}} \]
      6. add-sqr-sqrt30.2%

        \[\leadsto \frac{0.5}{\color{blue}{re}} \cdot \sqrt{\frac{0.25}{{re}^{2}}} \]
      7. sqrt-div30.2%

        \[\leadsto \frac{0.5}{re} \cdot \color{blue}{\frac{\sqrt{0.25}}{\sqrt{{re}^{2}}}} \]
      8. metadata-eval30.2%

        \[\leadsto \frac{0.5}{re} \cdot \frac{\color{blue}{0.5}}{\sqrt{{re}^{2}}} \]
      9. unpow230.2%

        \[\leadsto \frac{0.5}{re} \cdot \frac{0.5}{\sqrt{\color{blue}{re \cdot re}}} \]
      10. sqrt-prod16.6%

        \[\leadsto \frac{0.5}{re} \cdot \frac{0.5}{\color{blue}{\sqrt{re} \cdot \sqrt{re}}} \]
      11. add-sqr-sqrt17.0%

        \[\leadsto \frac{0.5}{re} \cdot \frac{0.5}{\color{blue}{re}} \]
    7. Applied egg-rr17.0%

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

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

Alternative 12: 48.8% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 30.0% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000018e27 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      7. fma-udef60.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 \cdot re + -0.08333333333333333 \cdot {re}^{3}\right) \]
      8. *-commutative60.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      9. *-commutative60.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + \color{blue}{{re}^{3} \cdot -0.08333333333333333}\right) \]
    8. Simplified60.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5 + {re}^{3} \cdot -0.08333333333333333\right)} \]
    9. Applied egg-rr9.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, re, re \cdot -0.16666666666666666\right)} \]
    10. Step-by-step derivation
      1. fma-udef9.3%

        \[\leadsto \color{blue}{re \cdot re + re \cdot -0.16666666666666666} \]
      2. distribute-lft-out9.3%

        \[\leadsto \color{blue}{re \cdot \left(re + -0.16666666666666666\right)} \]
    11. Simplified9.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.2 \cdot 10^{+27}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re + -0.16666666666666666\right)\\ \end{array} \]

Alternative 14: 4.3% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
  4. Applied egg-rr11.7%

    \[\leadsto \color{blue}{{\left(\sin re \cdot -2\right)}^{-2}} \]
  5. Taylor expanded in re around 0 11.5%

    \[\leadsto \color{blue}{0.08333333333333333 + 0.25 \cdot \frac{1}{{re}^{2}}} \]
  6. Step-by-step derivation
    1. associate-*r/11.5%

      \[\leadsto 0.08333333333333333 + \color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}} \]
    2. metadata-eval11.5%

      \[\leadsto 0.08333333333333333 + \frac{\color{blue}{0.25}}{{re}^{2}} \]
  7. Simplified11.5%

    \[\leadsto \color{blue}{0.08333333333333333 + \frac{0.25}{{re}^{2}}} \]
  8. Taylor expanded in re around inf 4.4%

    \[\leadsto \color{blue}{0.08333333333333333} \]
  9. Final simplification4.4%

    \[\leadsto 0.08333333333333333 \]

Alternative 15: 4.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
	return 1.0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 1.0d0
end function
public static double code(double re, double im) {
	return 1.0;
}
def code(re, im):
	return 1.0
function code(re, im)
	return 1.0
end
function tmp = code(re, im)
	tmp = 1.0;
end
code[re_, im_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-lft-in100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
    2. *-commutative100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
    3. cancel-sign-sub100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
    4. distribute-lft-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(-\left(0.5 \cdot \sin re\right) \cdot e^{im}\right)} \]
    5. *-commutative100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
    6. distribute-rgt-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
    7. neg-mul-1100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    8. associate-*r*100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    9. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
    11. neg-sub0100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
    12. *-commutative100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
    13. neg-mul-1100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
    14. remove-double-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
  4. Taylor expanded in re around 0 61.9%

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
  5. Simplified61.9%

    \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  6. Applied egg-rr4.8%

    \[\leadsto \color{blue}{\frac{re}{re}} \]
  7. Step-by-step derivation
    1. *-inverses4.8%

      \[\leadsto \color{blue}{1} \]
  8. Simplified4.8%

    \[\leadsto \color{blue}{1} \]
  9. Final simplification4.8%

    \[\leadsto 1 \]

Alternative 16: 27.5% accurate, 309.0× speedup?

\[\begin{array}{l} \\ re \end{array} \]
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
	return re;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = re
end function
public static double code(double re, double im) {
	return re;
}
def code(re, im):
	return re
function code(re, im)
	return re
end
function tmp = code(re, im)
	tmp = re;
end
code[re_, im_] := re
\begin{array}{l}

\\
re
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-lft-in100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
    2. *-commutative100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
    3. cancel-sign-sub100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
    4. distribute-lft-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(-\left(0.5 \cdot \sin re\right) \cdot e^{im}\right)} \]
    5. *-commutative100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
    6. distribute-rgt-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
    7. neg-mul-1100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    8. associate-*r*100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    9. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
    11. neg-sub0100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
    12. *-commutative100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
    13. neg-mul-1100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
    14. remove-double-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
  4. Taylor expanded in im around 0 77.9%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
  5. Simplified77.9%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
  6. Taylor expanded in re around 0 49.5%

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)} \]
  7. Step-by-step derivation
    1. *-commutative49.5%

      \[\leadsto \color{blue}{\left(re \cdot \left(2 + {im}^{2}\right)\right) \cdot 0.5} \]
    2. *-commutative49.5%

      \[\leadsto \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot re\right)} \cdot 0.5 \]
    3. associate-*l*49.5%

      \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(re \cdot 0.5\right)} \]
    4. +-commutative49.5%

      \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(re \cdot 0.5\right) \]
    5. unpow249.5%

      \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(re \cdot 0.5\right) \]
    6. fma-udef49.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(re \cdot 0.5\right) \]
  8. Simplified49.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(re \cdot 0.5\right)} \]
  9. Taylor expanded in im around 0 27.7%

    \[\leadsto \color{blue}{re} \]
  10. Final simplification27.7%

    \[\leadsto re \]

Reproduce

?
herbie shell --seed 2023311 
(FPCore (re im)
  :name "math.sin on complex, real part"
  :precision binary64
  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))