math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.7s
Alternatives: 18
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 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: 74.2% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 72.9% accurate, 2.4× speedup?

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

\mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot 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(2 + 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.00000000000000015e-5

    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 \color{blue}{\sin re} \]

    if 6.00000000000000015e-5 < 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 re around 0 77.3%

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

      \[\leadsto \left(0.5 \cdot 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. Taylor expanded in im around 0 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 6 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\ \;\;\;\;\left(0.5 \cdot 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(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.9% accurate, 2.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + 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 < 7.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 70.8%

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

    if 7.79999999999999982 < 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 re around 0 77.3%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \left(\color{blue}{3} + 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. Taylor expanded in im around 0 100.0%

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

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

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

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

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

Alternative 5: 71.6% accurate, 2.5× speedup?

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

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

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

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


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

    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 \color{blue}{\sin re} \]

    if 8 < im < 1.59999999999999997e151

    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 re around 0 80.0%

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

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

    if 1.59999999999999997e151 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 71.6% accurate, 2.5× speedup?

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

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

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

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


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

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

    if 7.79999999999999982 < im < 1.59999999999999997e151

    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 re around 0 80.0%

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

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

    if 1.59999999999999997e151 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 59.8% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 4.1 \cdot 10^{+75}:\\
\;\;\;\;{re}^{-2} \cdot 0.25\\

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


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

    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 \color{blue}{\sin re} \]

    if 850 < im < 4.0999999999999998e75

    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 re around 0 81.3%

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{0.25} \]
    7. Applied egg-rr8.6%

      \[\leadsto \color{blue}{{re}^{-2}} \cdot 0.25 \]

    if 4.0999999999999998e75 < 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 re around 0 72.3%

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

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)} \]
    8. Applied egg-rr55.3%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(re\right)} - -2\right)} \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    9. Step-by-step derivation
      1. log1p-undefine55.3%

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

        \[\leadsto \left(\color{blue}{\left(1 + re\right)} - -2\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
      3. +-commutative59.6%

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

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

        \[\leadsto \left(re + \color{blue}{3}\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    10. Simplified59.6%

      \[\leadsto \color{blue}{\left(re + 3\right)} \cdot \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 simplification64.8%

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

Alternative 8: 68.9% accurate, 2.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 7.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 70.8%

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

    if 7.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. Taylor expanded in re around 0 74.6%

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

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

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

Alternative 9: 68.8% accurate, 2.8× speedup?

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

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

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


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

    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 \color{blue}{\sin re} \]

    if 10.5 < 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 re around 0 74.6%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2, re, re\right)} \cdot \left(3 + e^{im}\right) \]
    8. Step-by-step derivation
      1. fma-undefine25.4%

        \[\leadsto \color{blue}{\left(-2 \cdot re + re\right)} \cdot \left(3 + e^{im}\right) \]
      2. distribute-lft1-in25.4%

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

        \[\leadsto \left(\color{blue}{-1} \cdot re\right) \cdot \left(3 + e^{im}\right) \]
      4. neg-mul-125.4%

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

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

        \[\leadsto \color{blue}{\left(\sqrt{-re} \cdot \sqrt{-re}\right)} \cdot \left(3 + e^{im}\right) \]
      2. sqrt-unprod44.4%

        \[\leadsto \color{blue}{\sqrt{\left(-re\right) \cdot \left(-re\right)}} \cdot \left(3 + e^{im}\right) \]
      3. sqr-neg44.4%

        \[\leadsto \sqrt{\color{blue}{re \cdot re}} \cdot \left(3 + e^{im}\right) \]
      4. sqrt-unprod49.2%

        \[\leadsto \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \cdot \left(3 + e^{im}\right) \]
      5. add-sqr-sqrt74.6%

        \[\leadsto \color{blue}{re} \cdot \left(3 + e^{im}\right) \]
      6. distribute-lft-in74.6%

        \[\leadsto \color{blue}{re \cdot 3 + re \cdot e^{im}} \]
    11. Applied egg-rr74.6%

      \[\leadsto \color{blue}{re \cdot 3 + re \cdot e^{im}} \]
    12. Step-by-step derivation
      1. distribute-lft-in74.6%

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

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

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

Alternative 10: 59.6% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.1 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\left(re + 3\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 4\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1.1e+16)
   (sin re)
   (*
    (+ re 3.0)
    (+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.1e+16) {
		tmp = sin(re);
	} else {
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 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.1d+16) then
        tmp = sin(re)
    else
        tmp = (re + 3.0d0) * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.1e+16) {
		tmp = Math.sin(re);
	} else {
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.1e+16:
		tmp = math.sin(re)
	else:
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.1e+16)
		tmp = sin(re);
	else
		tmp = Float64(Float64(re + 3.0) * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 4.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.1e+16)
		tmp = sin(re);
	else
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.1e+16], N[Sin[re], $MachinePrecision], N[(N[(re + 3.0), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.1 \cdot 10^{+16}:\\
\;\;\;\;\sin re\\

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


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

    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 68.7%

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

    if 1.1e16 < 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 re around 0 75.4%

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

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)} \]
    8. Applied egg-rr45.9%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(re\right)} - -2\right)} \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    9. Step-by-step derivation
      1. log1p-undefine45.9%

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

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

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

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

        \[\leadsto \left(re + \color{blue}{3}\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    10. Simplified51.2%

      \[\leadsto \color{blue}{\left(re + 3\right)} \cdot \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 simplification64.8%

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

Alternative 11: 35.4% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 125:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\left(re + 3\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 4\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 125.0)
   re
   (*
    (+ re 3.0)
    (+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = re;
	} else {
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 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 <= 125.0d0) then
        tmp = re
    else
        tmp = (re + 3.0d0) * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 125.0) {
		tmp = re;
	} else {
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 125.0:
		tmp = re
	else:
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 125.0)
		tmp = re;
	else
		tmp = Float64(Float64(re + 3.0) * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 4.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 125.0)
		tmp = re;
	else
		tmp = (re + 3.0) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 125.0], re, N[(N[(re + 3.0), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    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 re around 0 62.4%

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

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

    if 125 < 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 re around 0 74.6%

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

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

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(re\right)} - -2\right)} \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    9. Step-by-step derivation
      1. log1p-undefine41.6%

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

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

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

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

        \[\leadsto \left(re + \color{blue}{3}\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) \]
    10. Simplified46.5%

      \[\leadsto \color{blue}{\left(re + 3\right)} \cdot \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 simplification42.3%

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

Alternative 12: 40.0% accurate, 14.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 7.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 re around 0 62.4%

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

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

    if 7.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. Taylor expanded in re around 0 74.6%

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

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

      \[\leadsto \left(0.5 \cdot 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 simplification43.9%

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

Alternative 13: 40.0% accurate, 15.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 7.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 re around 0 62.4%

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

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

    if 7.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. Taylor expanded in re around 0 74.6%

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

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

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

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

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

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

Alternative 14: 37.1% accurate, 17.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 7.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 re around 0 62.4%

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

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

    if 7.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. Taylor expanded in re around 0 74.6%

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

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

      \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in37.9%

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

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

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

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

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

Alternative 15: 30.3% accurate, 19.3× speedup?

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

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

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


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

    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 re around 0 77.1%

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

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

    if 8200 < 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 re around 0 31.6%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2, re, re\right)} \cdot \left(3 + e^{im}\right) \]
    8. Step-by-step derivation
      1. fma-undefine18.6%

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

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

        \[\leadsto \left(\color{blue}{-1} \cdot re\right) \cdot \left(3 + e^{im}\right) \]
      4. neg-mul-118.6%

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

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

      \[\leadsto \left(-re\right) \cdot \color{blue}{\left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. distribute-lft-in28.8%

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

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

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

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

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

Alternative 16: 29.4% accurate, 25.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 7.8:\\ \;\;\;\;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 7.8) re (* (* 0.5 re) (+ im 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 7.8) {
		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 <= 7.8d0) 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 <= 7.8) {
		tmp = re;
	} else {
		tmp = (0.5 * re) * (im + 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 7.8:
		tmp = re
	else:
		tmp = (0.5 * re) * (im + 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 7.8)
		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 <= 7.8)
		tmp = re;
	else
		tmp = (0.5 * re) * (im + 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 7.8], re, N[(N[(0.5 * re), $MachinePrecision] * N[(im + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 7.8:\\
\;\;\;\;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 < 7.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 re around 0 62.4%

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

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

    if 7.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. Taylor expanded in re around 0 74.6%

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

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

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

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

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

Alternative 17: 29.0% accurate, 28.1× speedup?

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

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

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


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

    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 re around 0 77.1%

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

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

    if 8200 < 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 re around 0 31.6%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2, re, re\right)} \cdot \left(3 + e^{im}\right) \]
    8. Step-by-step derivation
      1. fma-undefine18.6%

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

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

        \[\leadsto \left(\color{blue}{-1} \cdot re\right) \cdot \left(3 + e^{im}\right) \]
      4. neg-mul-118.6%

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

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

      \[\leadsto \left(-re\right) \cdot \color{blue}{\left(4 + im\right)} \]
    11. Step-by-step derivation
      1. +-commutative18.6%

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

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

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

Alternative 18: 26.0% 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 re around 0 65.4%

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

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

Reproduce

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