math.sin on complex, real part

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 2: 93.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.01 \lor \neg \left(\sin re \leq 5 \cdot 10^{-16}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sin.f64 re) < -0.0100000000000000002 or 5.0000000000000004e-16 < (sin.f64 re)

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -0.0100000000000000002 < (sin.f64 re) < 5.0000000000000004e-16

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{re}{e^{im}}\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin re \leq -0.01 \lor \neg \left(\sin re \leq 5 \cdot 10^{-16}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{re}{e^{im}} + re \cdot e^{im}\right)\\ \end{array} \]

Alternative 3: 94.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq -9 \cdot 10^{+96}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -31000000:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 370:\\ \;\;\;\;t_0 \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(t_0 \cdot im\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))))
   (if (<= im -9e+96)
     (* (pow im 4.0) (* (sin re) 0.041666666666666664))
     (if (<= im -31000000.0)
       (* (+ (exp (- im)) (exp im)) (* 0.5 re))
       (if (<= im 370.0)
         (* t_0 (+ (+ 2.0 (* im im)) (* (pow im 4.0) 0.08333333333333333)))
         (log1p (expm1 (* im (* t_0 im)))))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if (im <= -9e+96) {
		tmp = pow(im, 4.0) * (sin(re) * 0.041666666666666664);
	} else if (im <= -31000000.0) {
		tmp = (exp(-im) + exp(im)) * (0.5 * re);
	} else if (im <= 370.0) {
		tmp = t_0 * ((2.0 + (im * im)) + (pow(im, 4.0) * 0.08333333333333333));
	} else {
		tmp = log1p(expm1((im * (t_0 * im))));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = 0.5 * Math.sin(re);
	double tmp;
	if (im <= -9e+96) {
		tmp = Math.pow(im, 4.0) * (Math.sin(re) * 0.041666666666666664);
	} else if (im <= -31000000.0) {
		tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
	} else if (im <= 370.0) {
		tmp = t_0 * ((2.0 + (im * im)) + (Math.pow(im, 4.0) * 0.08333333333333333));
	} else {
		tmp = Math.log1p(Math.expm1((im * (t_0 * im))));
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * math.sin(re)
	tmp = 0
	if im <= -9e+96:
		tmp = math.pow(im, 4.0) * (math.sin(re) * 0.041666666666666664)
	elif im <= -31000000.0:
		tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re)
	elif im <= 370.0:
		tmp = t_0 * ((2.0 + (im * im)) + (math.pow(im, 4.0) * 0.08333333333333333))
	else:
		tmp = math.log1p(math.expm1((im * (t_0 * im))))
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (im <= -9e+96)
		tmp = Float64((im ^ 4.0) * Float64(sin(re) * 0.041666666666666664));
	elseif (im <= -31000000.0)
		tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re));
	elseif (im <= 370.0)
		tmp = Float64(t_0 * Float64(Float64(2.0 + Float64(im * im)) + Float64((im ^ 4.0) * 0.08333333333333333)));
	else
		tmp = log1p(expm1(Float64(im * Float64(t_0 * im))));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -9e+96], N[(N[Power[im, 4.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -31000000.0], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 370.0], N[(t$95$0 * N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] + N[(N[Power[im, 4.0], $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[N[(im * N[(t$95$0 * im), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq -9 \cdot 10^{+96}:\\
\;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\

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

\mathbf{elif}\;im \leq 370:\\
\;\;\;\;t_0 \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -8.99999999999999914e96

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999914e96 < im < -3.1e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -3.1e7 < im < 370

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 370 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    10. Step-by-step derivation
      1. log1p-expm1-u94.9%

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{im \cdot \left(im \cdot \left(0.5 \cdot \sin re\right)\right)}\right)\right) \]
    11. Applied egg-rr94.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9 \cdot 10^{+96}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -31000000:\\ \;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 370:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(2 + im \cdot im\right) + {im}^{4} \cdot 0.08333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot \left(\left(0.5 \cdot \sin re\right) \cdot im\right)\right)\right)\\ \end{array} \]

Alternative 4: 95.7% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := {im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\
\mathbf{if}\;im \leq -9 \cdot 10^{+96}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -31000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 6.2:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -8.99999999999999914e96 or 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999914e96 < im < -3.1e7 or 6.20000000000000018 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -3.1e7 < im < 6.20000000000000018

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 5: 89.9% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\
\mathbf{if}\;im \leq -3.7:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 2.1 \cdot 10^{+21}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(e^{im}, re, re \cdot re\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.7000000000000002 or 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left({im}^{4} \cdot \sin re\right)} \cdot 0.041666666666666664 \]
      3. associate-*l*89.4%

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

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

    if -3.7000000000000002 < im < 2.1e21

    1. Initial program 100.0%

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

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

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

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

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

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

    if 2.1e21 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in71.4%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg71.4%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity71.4%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified71.4%

      \[\leadsto \color{blue}{0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{re}{e^{im}}\right)} \]
    7. Applied egg-rr71.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.7:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+21}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(e^{im}, re, re \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \end{array} \]

Alternative 6: 87.1% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.7 \lor \neg \left(im \leq 3.7\right):\\
\;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left({im}^{4} \cdot \sin re\right)} \cdot 0.041666666666666664 \]
      3. associate-*l*82.2%

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

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

    if -3.7000000000000002 < im < 3.7000000000000002

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.7 \lor \neg \left(im \leq 3.7\right):\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]

Alternative 7: 74.4% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 16500000000000:\\
\;\;\;\;\sin re\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.3e14

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
    12. Simplified52.4%

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

    if -3.3e14 < im < 1.65e13

    1. Initial program 100.0%

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

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

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

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

    if 1.65e13 < im < 2.90000000000000018e151

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 + {im}^{2}\right) \cdot \left(-1 \cdot \left(-1 \cdot re + 0.5 \cdot re\right)\right) + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{3} \cdot -0.08333333333333333\right)} \]
      10. distribute-lft-out29.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(-1 \cdot \left(-1 \cdot re + 0.5 \cdot re\right) + {re}^{3} \cdot -0.08333333333333333\right) \]
      14. distribute-rgt-out29.0%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(-1 \cdot \color{blue}{\left(re \cdot \left(-1 + 0.5\right)\right)} + {re}^{3} \cdot -0.08333333333333333\right) \]
      15. metadata-eval29.0%

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

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

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{\left(-1 \cdot -0.5\right) \cdot re} + {re}^{3} \cdot -0.08333333333333333\right) \]
      18. metadata-eval29.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    12. Simplified23.8%

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

    if 2.90000000000000018e151 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 71.1% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3200000000:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\

\mathbf{elif}\;im \leq 16500000000000:\\
\;\;\;\;\sin re\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -3.2e9

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
    12. Simplified52.4%

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

    if -3.2e9 < im < 1.65e13

    1. Initial program 100.0%

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

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

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

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

    if 1.65e13 < im < 6.3000000000000003e150

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 + {im}^{2}\right) \cdot \left(-1 \cdot \left(-1 \cdot re + 0.5 \cdot re\right)\right) + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{3} \cdot -0.08333333333333333\right)} \]
      10. distribute-lft-out29.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(-1 \cdot \left(-1 \cdot re + 0.5 \cdot re\right) + {re}^{3} \cdot -0.08333333333333333\right) \]
      14. distribute-rgt-out29.0%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(-1 \cdot \color{blue}{\left(re \cdot \left(-1 + 0.5\right)\right)} + {re}^{3} \cdot -0.08333333333333333\right) \]
      15. metadata-eval29.0%

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

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

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(\color{blue}{\left(-1 \cdot -0.5\right) \cdot re} + {re}^{3} \cdot -0.08333333333333333\right) \]
      18. metadata-eval29.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    12. Simplified23.8%

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

    if 6.3000000000000003e150 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3200000000:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\ \mathbf{elif}\;im \leq 16500000000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 6.3 \cdot 10^{+150}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + im \cdot im\right)\right)\\ \end{array} \]

Alternative 9: 75.1% accurate, 2.8× speedup?

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

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

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

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

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

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

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

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

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

Alternative 10: 70.4% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2050000000000:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\

\mathbf{elif}\;im \leq 1.02 \cdot 10^{+88}:\\
\;\;\;\;\sin re\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
    12. Simplified52.4%

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

    if -2.05e12 < im < 1.01999999999999998e88

    1. Initial program 100.0%

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

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

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

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

    if 1.01999999999999998e88 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 42.1% accurate, 27.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -31000000 \lor \neg \left(im \leq 6.2\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -31000000.0) (not (<= im 6.2))) (* 0.5 (* im (* re im))) re))
double code(double re, double im) {
	double tmp;
	if ((im <= -31000000.0) || !(im <= 6.2)) {
		tmp = 0.5 * (im * (re * im));
	} else {
		tmp = re;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-31000000.0d0)) .or. (.not. (im <= 6.2d0))) then
        tmp = 0.5d0 * (im * (re * im))
    else
        tmp = re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -31000000.0) || !(im <= 6.2)) {
		tmp = 0.5 * (im * (re * im));
	} else {
		tmp = re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -31000000.0) or not (im <= 6.2):
		tmp = 0.5 * (im * (re * im))
	else:
		tmp = re
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -31000000.0) || !(im <= 6.2))
		tmp = Float64(0.5 * Float64(im * Float64(re * im)));
	else
		tmp = re;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -31000000.0) || ~((im <= 6.2)))
		tmp = 0.5 * (im * (re * im));
	else
		tmp = re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -31000000.0], N[Not[LessEqual[im, 6.2]], $MachinePrecision]], N[(0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], re]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -31000000 \lor \neg \left(im \leq 6.2\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;re\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e7 < im < 6.20000000000000018

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.0%

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

Alternative 12: 47.2% accurate, 27.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -31000000 \lor \neg \left(im \leq 6.2\right):\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -31000000.0) (not (<= im 6.2))) (* (* 0.5 re) (* im im)) re))
double code(double re, double im) {
	double tmp;
	if ((im <= -31000000.0) || !(im <= 6.2)) {
		tmp = (0.5 * re) * (im * im);
	} else {
		tmp = re;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-31000000.0d0)) .or. (.not. (im <= 6.2d0))) then
        tmp = (0.5d0 * re) * (im * im)
    else
        tmp = re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -31000000.0) || !(im <= 6.2)) {
		tmp = (0.5 * re) * (im * im);
	} else {
		tmp = re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -31000000.0) or not (im <= 6.2):
		tmp = (0.5 * re) * (im * im)
	else:
		tmp = re
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -31000000.0) || !(im <= 6.2))
		tmp = Float64(Float64(0.5 * re) * Float64(im * im));
	else
		tmp = re;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -31000000.0) || ~((im <= 6.2)))
		tmp = (0.5 * re) * (im * im);
	else
		tmp = re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -31000000.0], N[Not[LessEqual[im, 6.2]], $MachinePrecision]], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision], re]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -31000000 \lor \neg \left(im \leq 6.2\right):\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;re\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e7 < im < 6.20000000000000018

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.0%

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

Alternative 13: 47.3% accurate, 34.3× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(re \cdot \left(2 + im \cdot im\right)\right) \end{array} \]
(FPCore (re im) :precision binary64 (* 0.5 (* re (+ 2.0 (* im im)))))
double code(double re, double im) {
	return 0.5 * (re * (2.0 + (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 * im)))
end function
public static double code(double re, double im) {
	return 0.5 * (re * (2.0 + (im * im)));
}
def code(re, im):
	return 0.5 * (re * (2.0 + (im * im)))
function code(re, im)
	return Float64(0.5 * Float64(re * Float64(2.0 + Float64(im * im))))
end
function tmp = code(re, im)
	tmp = 0.5 * (re * (2.0 + (im * im)));
end
code[re_, im_] := N[(0.5 * N[(re * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(2 + im \cdot im\right)\right)} \]
  10. Final simplification50.3%

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

Alternative 14: 3.5% accurate, 309.0× speedup?

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

\\
1.9380669946781485 \cdot 10^{-10}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sin re \cdot 1.9380669946781485 \cdot 10^{-10}}{\sin re + \left(\sin re \cdot 1.9380669946781485 \cdot 10^{-10} - \sin re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}} \]
  8. Step-by-step derivation
    1. *-commutative3.7%

      \[\leadsto \frac{\color{blue}{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}}{\sin re + \left(\sin re \cdot 1.9380669946781485 \cdot 10^{-10} - \sin re \cdot 1.9380669946781485 \cdot 10^{-10}\right)} \]
    2. +-inverses3.7%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}{\sin re + \color{blue}{0}} \]
    3. +-rgt-identity3.7%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}{\color{blue}{\sin re}} \]
    4. associate-/l*3.7%

      \[\leadsto \color{blue}{\frac{1.9380669946781485 \cdot 10^{-10}}{\frac{\sin re}{\sin re}}} \]
    5. *-inverses3.7%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10}}{\color{blue}{1}} \]
    6. metadata-eval3.7%

      \[\leadsto \color{blue}{1.9380669946781485 \cdot 10^{-10}} \]
  9. Simplified3.7%

    \[\leadsto \color{blue}{1.9380669946781485 \cdot 10^{-10}} \]
  10. Final simplification3.7%

    \[\leadsto 1.9380669946781485 \cdot 10^{-10} \]

Alternative 15: 4.6% accurate, 309.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-2 \cdot \sin re}{-2 \cdot \sin re + \left(-2 \cdot \sin re - -2 \cdot \sin re\right)}} \]
  5. Step-by-step derivation
    1. +-inverses5.0%

      \[\leadsto \frac{-2 \cdot \sin re}{-2 \cdot \sin re + \color{blue}{0}} \]
    2. +-rgt-identity5.0%

      \[\leadsto \frac{-2 \cdot \sin re}{\color{blue}{-2 \cdot \sin re}} \]
    3. *-inverses5.0%

      \[\leadsto \color{blue}{1} \]
  6. Simplified5.0%

    \[\leadsto \color{blue}{1} \]
  7. Final simplification5.0%

    \[\leadsto 1 \]

Alternative 16: 26.1% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto re \]

Reproduce

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