math.exp on complex, imaginary part

Percentage Accurate: 100.0% → 100.0%
Time: 7.6s
Alternatives: 14
Speedup: 1.0×

Specification

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

\\
e^{re} \cdot \sin im
\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 14 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} \\ e^{re} \cdot \sin im \end{array} \]
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
	return exp(re) * sin(im);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
	return Math.exp(re) * Math.sin(im);
}
def code(re, im):
	return math.exp(re) * math.sin(im)
function code(re, im)
	return Float64(exp(re) * sin(im))
end
function tmp = code(re, im)
	tmp = exp(re) * sin(im);
end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{re} \cdot \sin im
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
e^{re} \cdot \sin im
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{re} \cdot \sin im \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 92.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999999999 \lor \neg \left(e^{re} \leq 1.2\right):\\
\;\;\;\;e^{re} \cdot im\\

\mathbf{else}:\\
\;\;\;\;\sin im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 re) < 0.99999999999 or 1.19999999999999996 < (exp.f64 re)

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 83.6%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]

    if 0.99999999999 < (exp.f64 re) < 1.19999999999999996

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 99.2%

      \[\leadsto \color{blue}{\sin im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.7%

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

Alternative 3: 86.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-15} \lor \neg \left(e^{re} \leq 2 \cdot 10^{+30}\right):\\
\;\;\;\;e^{re}\\

\mathbf{else}:\\
\;\;\;\;\sin im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 re) < 4.99999999999999999e-15 or 2e30 < (exp.f64 re)

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log56.1%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp56.0%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr56.0%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 78.9%

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

    if 4.99999999999999999e-15 < (exp.f64 re) < 2e30

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 95.7%

      \[\leadsto \color{blue}{\sin im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.1%

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

Alternative 4: 92.4% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;re \leq 0.0295:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\
\;\;\;\;e^{re} \cdot im\\

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

\mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if re < -25 or 1.3999999999999999e89 < re < 1.13999999999999997e154

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log54.9%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp54.9%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr54.9%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 91.7%

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

    if -25 < re < 0.029499999999999998 or 1.13999999999999997e154 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 92.7%

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

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

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

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

        \[\leadsto \sin im \cdot 1 + \left(re \cdot \sin im + \color{blue}{\left(re \cdot \left(0.5 \cdot re\right)\right) \cdot \sin im}\right) \]
      5. distribute-rgt-out99.2%

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

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

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

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

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

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

    if 0.029499999999999998 < re < 4.7e24

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 66.8%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]

    if 4.7e24 < re < 1.3999999999999999e89

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 3.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -25:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.0295:\\ \;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{elif}\;re \leq 1.4 \cdot 10^{+89}:\\ \;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im + -0.16666666666666666 \cdot {im}^{3}\right)\\ \mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 92.4% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;re \leq 0.037:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\
\;\;\;\;e^{re} \cdot im\\

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

\mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if re < -32 or 1.3999999999999999e89 < re < 1.13999999999999997e154

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log54.9%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp54.9%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr54.9%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 91.7%

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

    if -32 < re < 0.0369999999999999982 or 1.13999999999999997e154 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 92.7%

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

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

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

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

        \[\leadsto \sin im \cdot 1 + \left(re \cdot \sin im + \color{blue}{\left(re \cdot \left(0.5 \cdot re\right)\right) \cdot \sin im}\right) \]
      5. distribute-rgt-out99.2%

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

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

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

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

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

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

    if 0.0369999999999999982 < re < 4.7e24

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 66.8%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]

    if 4.7e24 < re < 1.3999999999999999e89

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 3.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -32:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.037:\\ \;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{elif}\;re \leq 1.4 \cdot 10^{+89}:\\ \;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right)\\ \mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 96.5% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -25:\\
\;\;\;\;e^{re}\\

\mathbf{elif}\;re \leq 0.017 \lor \neg \left(re \leq 1.14 \cdot 10^{+154}\right):\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\


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

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log55.1%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp55.0%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr55.0%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 98.8%

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

    if -25 < re < 0.017000000000000001 or 1.13999999999999997e154 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 92.7%

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

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

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

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

        \[\leadsto \sin im \cdot 1 + \left(re \cdot \sin im + \color{blue}{\left(re \cdot \left(0.5 \cdot re\right)\right) \cdot \sin im}\right) \]
      5. distribute-rgt-out99.2%

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

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

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

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

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

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

    if 0.017000000000000001 < re < 1.13999999999999997e154

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 63.4%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.9%

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

Alternative 7: 93.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;e^{re}\\

\mathbf{elif}\;re \leq 0.0135:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\

\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\


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

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log55.1%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp55.0%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr55.0%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 98.8%

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

    if -1 < re < 0.0134999999999999998

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 99.2%

      \[\leadsto \color{blue}{\sin im + re \cdot \sin im} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in99.2%

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

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

    if 0.0134999999999999998 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 67.7%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.1%

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

Alternative 8: 62.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.00115 \lor \neg \left(re \leq 9.5 \cdot 10^{-30}\right):\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.00115 or 9.49999999999999939e-30 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log55.4%

        \[\leadsto e^{re} \cdot \color{blue}{e^{\log \sin im}} \]
      2. prod-exp55.4%

        \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    4. Applied egg-rr55.4%

      \[\leadsto \color{blue}{e^{re + \log \sin im}} \]
    5. Taylor expanded in re around inf 75.5%

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

    if -0.00115 < re < 9.49999999999999939e-30

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 51.9%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    4. Taylor expanded in re around 0 51.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.00115 \lor \neg \left(re \leq 9.5 \cdot 10^{-30}\right):\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;im + re \cdot \left(im + re \cdot \left(0.16666666666666666 \cdot \left(re \cdot im\right) + im \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 49.4% accurate, 12.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;im \cdot t\_0\\


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

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 2.2%

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

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

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

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

        \[\leadsto \sin im \cdot 1 + \left(re \cdot \sin im + \color{blue}{\left(re \cdot \left(0.5 \cdot re\right)\right) \cdot \sin im}\right) \]
      5. distribute-rgt-out2.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin im\right)\right)} \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \]
      2. expm1-undefine30.3%

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

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

        \[\leadsto \left(\color{blue}{\left(1 + \sin im\right)} - 1\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \]
    7. Applied egg-rr30.3%

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

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

    if -52 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 78.3%

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

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

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

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

        \[\leadsto \sin im \cdot 1 + \left(re \cdot \sin im + \color{blue}{\left(re \cdot \left(0.5 \cdot re\right)\right) \cdot \sin im}\right) \]
      5. distribute-rgt-out83.8%

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

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

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

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

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

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

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

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

Alternative 10: 38.1% accurate, 18.5× speedup?

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

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

    \[e^{re} \cdot \sin im \]
  2. Add Preprocessing
  3. Taylor expanded in re around 0 58.1%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 34.7% accurate, 22.6× speedup?

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

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

    \[e^{re} \cdot \sin im \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 67.5%

    \[\leadsto e^{re} \cdot \color{blue}{im} \]
  4. Taylor expanded in re around 0 32.4%

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

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

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

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

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

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

Alternative 12: 30.2% accurate, 25.3× speedup?

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

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

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


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

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 65.3%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    4. Taylor expanded in re around 0 29.8%

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

    if 1.3999999999999999e89 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 4.6%

      \[\leadsto \color{blue}{\sin im + re \cdot \sin im} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in4.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.4 \cdot 10^{+89}:\\ \;\;\;\;im\\ \mathbf{else}:\\ \;\;\;\;re \cdot im\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 30.4% accurate, 40.6× speedup?

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

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

    \[e^{re} \cdot \sin im \]
  2. Add Preprocessing
  3. Taylor expanded in re around 0 49.2%

    \[\leadsto \color{blue}{\sin im + re \cdot \sin im} \]
  4. Step-by-step derivation
    1. distribute-rgt1-in49.2%

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

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

    \[\leadsto \left(re + 1\right) \cdot \color{blue}{im} \]
  7. Final simplification28.5%

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

Alternative 14: 27.3% accurate, 203.0× speedup?

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

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

    \[e^{re} \cdot \sin im \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 67.5%

    \[\leadsto e^{re} \cdot \color{blue}{im} \]
  4. Taylor expanded in re around 0 24.7%

    \[\leadsto \color{blue}{im} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024101 
(FPCore (re im)
  :name "math.exp on complex, imaginary part"
  :precision binary64
  (* (exp re) (sin im)))