math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.5s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.4% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 1.0500000000000001e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 2.2:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))))
   (if (<= im 2.2) (* t_0 (fma im im 2.0)) (* t_0 (+ (exp im) 3.0)))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if (im <= 2.2) {
		tmp = t_0 * fma(im, im, 2.0);
	} else {
		tmp = t_0 * (exp(im) + 3.0);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (im <= 2.2)
		tmp = Float64(t_0 * fma(im, im, 2.0));
	else
		tmp = Float64(t_0 * Float64(exp(im) + 3.0));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.2], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2000000000000002 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 75.3% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 2.2000000000000002 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.1% accurate, 2.3× speedup?

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

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

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+99}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 4.79999999999999982 < im < 2.6e99

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(3 + e^{im}\right) \cdot \left(re \cdot 0.5\right)} \]
    8. Simplified84.6%

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

    if 2.6e99 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 89.2% accurate, 2.3× speedup?

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

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

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+99}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 6 < im < 2.6e99

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(3 + e^{im}\right) \cdot \left(re \cdot 0.5\right)} \]
    8. Simplified84.6%

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

    if 2.6e99 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 85.4% accurate, 2.4× speedup?

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

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

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+99}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 4.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. distribute-rgt-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \color{blue}{\left(1 + \left(im \cdot \left(im \cdot 0.5 - 1\right) + \left(1 + im\right)\right)\right)}\right) \]
      3. fma-define81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \color{blue}{\mathsf{fma}\left(im, im \cdot 0.5 - 1, 1 + im\right)}\right)\right) \]
      4. *-commutative81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \color{blue}{0.5 \cdot im} - 1, 1 + im\right)\right)\right) \]
      5. fmm-def81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}, 1 + im\right)\right)\right) \]
      6. metadata-eval81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right), 1 + im\right)\right)\right) \]
    11. Applied egg-rr81.9%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(1 \cdot \left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right)\right)\right)} \]
    12. Step-by-step derivation
      1. *-lft-identity81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right)\right)} \]
      2. +-commutative81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right) + 1\right)} \]
      3. fma-undefine81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + \left(1 + im\right)\right)} + 1\right) \]
      4. associate-+r+81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + 1\right) + im\right)} + 1\right) \]
      5. fma-undefine81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right)} + im\right) + 1\right) \]
      6. associate-+r+81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + \left(im + 1\right)\right)} \]
      7. +-commutative81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + \color{blue}{\left(1 + im\right)}\right) \]
      8. associate-+r+81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + 1\right) + im\right)} \]
      9. +-commutative81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right)\right)} + im\right) \]
      10. *-rgt-identity81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) \cdot 1}\right) + im\right) \]
      11. fma-undefine81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + 1\right)} \cdot 1\right) + im\right) \]
      12. distribute-rgt1-in81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(1 + \left(im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right) \cdot 1\right)}\right) + im\right) \]
      13. *-rgt-identity81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \left(1 + \color{blue}{im \cdot \mathsf{fma}\left(0.5, im, -1\right)}\right)\right) + im\right) \]
      14. associate-+r+81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(\left(1 + 1\right) + im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right)} + im\right) \]
      15. metadata-eval81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{2} + im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right) + im\right) \]
      16. associate-+r+81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + \left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + im\right)\right)} \]
      17. metadata-eval81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right) + im\right)\right) \]
      18. fmm-def81.9%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \color{blue}{\left(im + im \cdot \left(0.5 \cdot im - 1\right)\right)}\right) \]
      20. *-rgt-identity81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(\color{blue}{im \cdot 1} + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
      21. fmm-def81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot 1 + im \cdot \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}\right)\right) \]
      22. metadata-eval81.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot 1 + im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right)\right)\right) \]
    13. Simplified81.9%

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

    if 4.20000000000000018 < im < 2.6e99

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(3 + e^{im}\right) \cdot \left(re \cdot 0.5\right)} \]
    8. Simplified84.6%

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

    if 2.6e99 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 84.4% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.8 \lor \neg \left(im \leq 1.85 \cdot 10^{+154}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(0.5 \cdot im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4.79999999999999982 or 1.84999999999999997e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \color{blue}{\left(1 + \left(im \cdot \left(im \cdot 0.5 - 1\right) + \left(1 + im\right)\right)\right)}\right) \]
      3. fma-define85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \color{blue}{\mathsf{fma}\left(im, im \cdot 0.5 - 1, 1 + im\right)}\right)\right) \]
      4. *-commutative85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \color{blue}{0.5 \cdot im} - 1, 1 + im\right)\right)\right) \]
      5. fmm-def85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}, 1 + im\right)\right)\right) \]
      6. metadata-eval85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(1 \cdot \left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right), 1 + im\right)\right)\right) \]
    11. Applied egg-rr85.8%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(1 \cdot \left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right)\right)\right)} \]
    12. Step-by-step derivation
      1. *-lft-identity85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right)\right)} \]
      2. +-commutative85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1 + im\right) + 1\right)} \]
      3. fma-undefine85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + \left(1 + im\right)\right)} + 1\right) \]
      4. associate-+r+85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + 1\right) + im\right)} + 1\right) \]
      5. fma-undefine85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right)} + im\right) + 1\right) \]
      6. associate-+r+85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + \left(im + 1\right)\right)} \]
      7. +-commutative85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + \color{blue}{\left(1 + im\right)}\right) \]
      8. associate-+r+85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) + 1\right) + im\right)} \]
      9. +-commutative85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(1 + \mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right)\right)} + im\right) \]
      10. *-rgt-identity85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\mathsf{fma}\left(im, \mathsf{fma}\left(0.5, im, -1\right), 1\right) \cdot 1}\right) + im\right) \]
      11. fma-undefine85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + 1\right)} \cdot 1\right) + im\right) \]
      12. distribute-rgt1-in85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \color{blue}{\left(1 + \left(im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right) \cdot 1\right)}\right) + im\right) \]
      13. *-rgt-identity85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + \left(1 + \color{blue}{im \cdot \mathsf{fma}\left(0.5, im, -1\right)}\right)\right) + im\right) \]
      14. associate-+r+85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(\left(1 + 1\right) + im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right)} + im\right) \]
      15. metadata-eval85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{2} + im \cdot \mathsf{fma}\left(0.5, im, -1\right)\right) + im\right) \]
      16. associate-+r+85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + \left(im \cdot \mathsf{fma}\left(0.5, im, -1\right) + im\right)\right)} \]
      17. metadata-eval85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right) + im\right)\right) \]
      18. fmm-def85.8%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(\color{blue}{im \cdot 1} + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
      21. fmm-def85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot 1 + im \cdot \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}\right)\right) \]
      22. metadata-eval85.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + \left(im \cdot 1 + im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right)\right)\right) \]
    13. Simplified85.8%

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

    if 4.79999999999999982 < im < 1.84999999999999997e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.1% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 4.79999999999999982 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 64.5% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 410 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 47.7% accurate, 11.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.5 \cdot 10^{+87} \lor \neg \left(re \leq 8.4 \cdot 10^{+225}\right):\\
\;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 2.4999999999999999e87 or 8.39999999999999999e225 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot \left(2 + \left(im + im \cdot \left(0.5 \cdot im - 1\right)\right)\right)\right)} \]
      4. distribute-lft-in55.0%

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

        \[\leadsto re \cdot \left(\color{blue}{1} + 0.5 \cdot \left(im + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
      6. *-rgt-identity55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(\color{blue}{im \cdot 1} + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
      7. fmm-def55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot 1 + im \cdot \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}\right)\right) \]
      8. metadata-eval55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot 1 + im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right)\right)\right) \]
      9. distribute-lft-out55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \color{blue}{\left(im \cdot \left(1 + \mathsf{fma}\left(0.5, im, -1\right)\right)\right)}\right) \]
      10. fma-undefine55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(1 + \color{blue}{\left(0.5 \cdot im + -1\right)}\right)\right)\right) \]
      11. associate-+l+55.0%

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

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(\color{blue}{\left(0.5 \cdot im + 1\right)} + -1\right)\right)\right) \]
      13. associate-+l+55.0%

        \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \color{blue}{\left(0.5 \cdot im + \left(1 + -1\right)\right)}\right)\right) \]
      14. metadata-eval55.0%

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

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

    if 2.4999999999999999e87 < re < 8.39999999999999999e225

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(2 + \left(im + im \cdot \left(im \cdot \left(0.5 + -0.16666666666666666 \cdot im\right) - 1\right)\right)\right)\right)} \]
    8. Taylor expanded in im around inf 20.9%

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(2 + \left(im + im \cdot \left(im \cdot \color{blue}{\left(im \cdot -0.16666666666666666\right)} - 1\right)\right)\right)\right) \]
    10. Simplified20.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.5 \cdot 10^{+87} \lor \neg \left(re \leq 8.4 \cdot 10^{+225}\right):\\ \;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + \left(im + im \cdot \left(im \cdot \left(im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 30.1% accurate, 25.7× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 1.1000000000000001 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 47.7% accurate, 28.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot \left(2 + \left(im + im \cdot \left(0.5 \cdot im - 1\right)\right)\right)\right)} \]
    4. distribute-lft-in51.1%

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

      \[\leadsto re \cdot \left(\color{blue}{1} + 0.5 \cdot \left(im + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
    6. *-rgt-identity51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(\color{blue}{im \cdot 1} + im \cdot \left(0.5 \cdot im - 1\right)\right)\right) \]
    7. fmm-def51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot 1 + im \cdot \color{blue}{\mathsf{fma}\left(0.5, im, -1\right)}\right)\right) \]
    8. metadata-eval51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot 1 + im \cdot \mathsf{fma}\left(0.5, im, \color{blue}{-1}\right)\right)\right) \]
    9. distribute-lft-out51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \color{blue}{\left(im \cdot \left(1 + \mathsf{fma}\left(0.5, im, -1\right)\right)\right)}\right) \]
    10. fma-undefine51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(1 + \color{blue}{\left(0.5 \cdot im + -1\right)}\right)\right)\right) \]
    11. associate-+l+51.1%

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

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(\color{blue}{\left(0.5 \cdot im + 1\right)} + -1\right)\right)\right) \]
    13. associate-+l+51.1%

      \[\leadsto re \cdot \left(1 + 0.5 \cdot \left(im \cdot \color{blue}{\left(0.5 \cdot im + \left(1 + -1\right)\right)}\right)\right) \]
    14. metadata-eval51.1%

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

    \[\leadsto \color{blue}{re \cdot \left(1 + 0.5 \cdot \left(im \cdot \left(0.5 \cdot im + 0\right)\right)\right)} \]
  13. Final simplification51.1%

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

Alternative 14: 27.4% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 3.0% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{2} \]
  6. Applied egg-rr2.8%

    \[\leadsto \color{blue}{\log \left({1}^{\sin re}\right)} \cdot 2 \]
  7. Step-by-step derivation
    1. pow-base-12.8%

      \[\leadsto \log \color{blue}{1} \cdot 2 \]
    2. metadata-eval2.8%

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

    \[\leadsto \color{blue}{0} \cdot 2 \]
  9. Step-by-step derivation
    1. metadata-eval2.8%

      \[\leadsto \color{blue}{0} \]
  10. Applied egg-rr2.8%

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

Reproduce

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