math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 9.6s
Alternatives: 18
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 18 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, 0.8× speedup?

\[\begin{array}{l} \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
	return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im)
	return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im))))
end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{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. +-commutative100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
    10. exp-diff100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    11. associate-*l/100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
    12. exp-0100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 73.2% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(-im\right)}\right) + e^{im}\right) \]
      2. unsub-neg69.7%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
    10. Simplified68.4%

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

    if 1.15e6 < im < 1.1600000000000001e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1600000000000001e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 94.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.2% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.2% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{1} + e^{im}\right) \]
  9. Final simplification77.5%

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

Alternative 6: 72.6% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot 0.5\\ t_1 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\ \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(t\_1 + 2\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (sin re) 0.5))
        (t_1 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))
   (if (<= im 1150000.0)
     (* t_0 (+ (- 1.0 im) (+ 1.0 t_1)))
     (if (<= im 1.02e+103)
       (* (+ (exp im) 1.0) (* re 0.5))
       (* t_0 (+ t_1 2.0))))))
double code(double re, double im) {
	double t_0 = sin(re) * 0.5;
	double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
	double tmp;
	if (im <= 1150000.0) {
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	} else if (im <= 1.02e+103) {
		tmp = (exp(im) + 1.0) * (re * 0.5);
	} else {
		tmp = t_0 * (t_1 + 2.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sin(re) * 0.5d0
    t_1 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
    if (im <= 1150000.0d0) then
        tmp = t_0 * ((1.0d0 - im) + (1.0d0 + t_1))
    else if (im <= 1.02d+103) then
        tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
    else
        tmp = t_0 * (t_1 + 2.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.sin(re) * 0.5;
	double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
	double tmp;
	if (im <= 1150000.0) {
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	} else if (im <= 1.02e+103) {
		tmp = (Math.exp(im) + 1.0) * (re * 0.5);
	} else {
		tmp = t_0 * (t_1 + 2.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.sin(re) * 0.5
	t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))
	tmp = 0
	if im <= 1150000.0:
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1))
	elif im <= 1.02e+103:
		tmp = (math.exp(im) + 1.0) * (re * 0.5)
	else:
		tmp = t_0 * (t_1 + 2.0)
	return tmp
function code(re, im)
	t_0 = Float64(sin(re) * 0.5)
	t_1 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))
	tmp = 0.0
	if (im <= 1150000.0)
		tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + t_1)));
	elseif (im <= 1.02e+103)
		tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5));
	else
		tmp = Float64(t_0 * Float64(t_1 + 2.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = sin(re) * 0.5;
	t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
	tmp = 0.0;
	if (im <= 1150000.0)
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	elseif (im <= 1.02e+103)
		tmp = (exp(im) + 1.0) * (re * 0.5);
	else
		tmp = t_0 * (t_1 + 2.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1150000.0], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 + 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin re \cdot 0.5\\
t_1 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\

\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + 2\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(-im\right)}\right) + e^{im}\right) \]
      2. unsub-neg69.7%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
    10. Simplified68.4%

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

    if 1.15e6 < im < 1.01999999999999991e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.3% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot 0.5\\ \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (sin re) 0.5)))
   (if (<= im 1150000.0)
     (* t_0 (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
     (if (<= im 1.02e+103)
       (* (+ (exp im) 1.0) (* re 0.5))
       (*
        t_0
        (+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 2.0))))))
double code(double re, double im) {
	double t_0 = sin(re) * 0.5;
	double tmp;
	if (im <= 1150000.0) {
		tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
	} else if (im <= 1.02e+103) {
		tmp = (exp(im) + 1.0) * (re * 0.5);
	} else {
		tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(re) * 0.5d0
    if (im <= 1150000.0d0) then
        tmp = t_0 * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
    else if (im <= 1.02d+103) then
        tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
    else
        tmp = t_0 * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 2.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.sin(re) * 0.5;
	double tmp;
	if (im <= 1150000.0) {
		tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
	} else if (im <= 1.02e+103) {
		tmp = (Math.exp(im) + 1.0) * (re * 0.5);
	} else {
		tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.sin(re) * 0.5
	tmp = 0
	if im <= 1150000.0:
		tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))))
	elif im <= 1.02e+103:
		tmp = (math.exp(im) + 1.0) * (re * 0.5)
	else:
		tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0)
	return tmp
function code(re, im)
	t_0 = Float64(sin(re) * 0.5)
	tmp = 0.0
	if (im <= 1150000.0)
		tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))));
	elseif (im <= 1.02e+103)
		tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5));
	else
		tmp = Float64(t_0 * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 2.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = sin(re) * 0.5;
	tmp = 0.0;
	if (im <= 1150000.0)
		tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
	elseif (im <= 1.02e+103)
		tmp = (exp(im) + 1.0) * (re * 0.5);
	else
		tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[im, 1150000.0], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin re \cdot 0.5\\
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\

\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(-im\right)}\right) + e^{im}\right) \]
      2. unsub-neg69.7%

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

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

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

    if 1.15e6 < im < 1.01999999999999991e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.3% accurate, 2.4× speedup?

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

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

\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(-im\right)}\right) + e^{im}\right) \]
      2. unsub-neg69.7%

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

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

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

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

    if 1.15e6 < im < 1.01999999999999991e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 84.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1150000 \lor \neg \left(im \leq 1.5 \cdot 10^{+147}\right):\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 1150000.0) (not (<= im 1.5e+147)))
   (* 0.5 (* (sin re) (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)))
   (* (+ (exp im) 1.0) (* re 0.5))))
double code(double re, double im) {
	double tmp;
	if ((im <= 1150000.0) || !(im <= 1.5e+147)) {
		tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = (exp(im) + 1.0) * (re * 0.5);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= 1150000.0d0) .or. (.not. (im <= 1.5d+147))) then
        tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
    else
        tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= 1150000.0) || !(im <= 1.5e+147)) {
		tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = (Math.exp(im) + 1.0) * (re * 0.5);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 1150000.0) or not (im <= 1.5e+147):
		tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im))
	else:
		tmp = (math.exp(im) + 1.0) * (re * 0.5)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 1150000.0) || !(im <= 1.5e+147))
		tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im)));
	else
		tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= 1150000.0) || ~((im <= 1.5e+147)))
		tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	else
		tmp = (exp(im) + 1.0) * (re * 0.5);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, 1150000.0], N[Not[LessEqual[im, 1.5e+147]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000 \lor \neg \left(im \leq 1.5 \cdot 10^{+147}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 1.15e6 or 1.49999999999999997e147 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.15e6 < im < 1.49999999999999997e147

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
    11. Simplified71.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000 \lor \neg \left(im \leq 1.5 \cdot 10^{+147}\right):\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 72.0% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;im \leq 1.5 \cdot 10^{+147}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\

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


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

    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. +-commutative100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.2%

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

    if 1.15e6 < im < 1.49999999999999997e147

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
    11. Simplified71.1%

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

    if 1.49999999999999997e147 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1150000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+147}:\\ \;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 69.3% accurate, 2.8× speedup?

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

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

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


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

    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. +-commutative100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.2%

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

    if 1.15e6 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 65.2% accurate, 2.9× speedup?

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

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

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+54}:\\
\;\;\;\;re \cdot \left(2 + -0.3333333333333333 \cdot \left(re \cdot re\right)\right)\\

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


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

    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. +-commutative100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.2%

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

    if 500 < im < 2.70000000000000011e54

    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. +-commutative100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Applied egg-rr2.6%

      \[\leadsto \color{blue}{\sin re + \sin re} \]
    6. Step-by-step derivation
      1. count-22.6%

        \[\leadsto \color{blue}{2 \cdot \sin re} \]
    7. Simplified2.6%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
    8. Taylor expanded in re around 0 30.6%

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

        \[\leadsto re \cdot \left(2 + -0.3333333333333333 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    10. Applied egg-rr30.6%

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

    if 2.70000000000000011e54 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
    11. Simplified76.8%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right) \]
    14. Simplified63.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 500:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+54}:\\ \;\;\;\;re \cdot \left(2 + -0.3333333333333333 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 44.7% accurate, 18.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
  11. Simplified46.6%

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right) \]
  14. Simplified42.0%

    \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)} \]
  15. Final simplification42.0%

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

Alternative 14: 48.0% accurate, 20.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)} \]
  10. Add Preprocessing

Alternative 15: 47.7% accurate, 23.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
  11. Simplified46.6%

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + \color{blue}{im \cdot 0.5}\right)\right) \]
  14. Simplified49.7%

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

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

Alternative 16: 32.6% accurate, 44.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(1 + e^{im}\right) \]
  11. Simplified46.6%

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

    \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(2 + im\right)} \]
  13. Final simplification30.8%

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

Alternative 17: 26.7% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
    10. exp-diff100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    11. associate-*l/100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
    12. exp-0100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in im around 0 50.2%

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

    \[\leadsto \color{blue}{re} \]
  7. Add Preprocessing

Alternative 18: 2.9% accurate, 309.0× speedup?

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

\\
0
\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. +-commutative100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
    10. exp-diff100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    11. associate-*l/100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
    12. exp-0100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr2.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \sin re \cdot -0.5, \sin re \cdot -0.5\right)} \]
  6. Step-by-step derivation
    1. fma-undefine2.8%

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot -0.5\right) \cdot \sin re} + \sin re \cdot -0.5 \]
    4. metadata-eval2.8%

      \[\leadsto \color{blue}{0.5} \cdot \sin re + \sin re \cdot -0.5 \]
    5. +-commutative2.8%

      \[\leadsto \color{blue}{\sin re \cdot -0.5 + 0.5 \cdot \sin re} \]
    6. metadata-eval2.8%

      \[\leadsto \sin re \cdot -0.5 + \color{blue}{\left(--0.5\right)} \cdot \sin re \]
    7. distribute-lft-neg-in2.8%

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

      \[\leadsto \sin re \cdot -0.5 + \left(-\color{blue}{\sin re \cdot -0.5}\right) \]
    9. sub-neg2.8%

      \[\leadsto \color{blue}{\sin re \cdot -0.5 - \sin re \cdot -0.5} \]
    10. +-inverses2.8%

      \[\leadsto \color{blue}{0} \]
  7. Simplified2.8%

    \[\leadsto \color{blue}{0} \]
  8. Add Preprocessing

Reproduce

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