math.exp on complex, imaginary part

Percentage Accurate: 100.0% → 100.0%
Time: 8.3s
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: 86.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 2\right):\\
\;\;\;\;e^{re}\\

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


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

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity76.7%

        \[\leadsto e^{\color{blue}{1 \cdot \log \left(e^{re} \cdot \sin im\right)}} \]
      3. exp-prod76.7%

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod50.0%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp50.0%

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

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 76.7%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity76.7%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-176.7%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp76.7%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity76.7%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr76.7%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity76.7%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified76.7%

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

    if 0.0 < (exp.f64 re) < 2

    1. Initial program 100.0%

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

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

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

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

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

Alternative 3: 69.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.00000005\right):\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{else}:\\ \;\;\;\;\sin im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.00000005)))
   (* (exp re) im)
   (sin im)))
double code(double re, double im) {
	double tmp;
	if ((exp(re) <= 1.0) || !(exp(re) <= 1.00000005)) {
		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) <= 1.0d0) .or. (.not. (exp(re) <= 1.00000005d0))) 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) <= 1.0) || !(Math.exp(re) <= 1.00000005)) {
		tmp = Math.exp(re) * im;
	} else {
		tmp = Math.sin(im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (math.exp(re) <= 1.0) or not (math.exp(re) <= 1.00000005):
		tmp = math.exp(re) * im
	else:
		tmp = math.sin(im)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((exp(re) <= 1.0) || !(exp(re) <= 1.00000005))
		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) <= 1.0) || ~((exp(re) <= 1.00000005)))
		tmp = exp(re) * im;
	else
		tmp = sin(im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.00000005]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.00000005\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) < 1 or 1.00000004999999992 < (exp.f64 re)

    1. Initial program 100.0%

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

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

    if 1 < (exp.f64 re) < 1.00000004999999992

    1. Initial program 100.0%

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

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

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

Alternative 4: 85.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 2\right):\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\sin im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= (exp re) 0.0) (not (<= (exp re) 2.0))) (exp re) (sin im)))
double code(double re, double im) {
	double tmp;
	if ((exp(re) <= 0.0) || !(exp(re) <= 2.0)) {
		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) <= 0.0d0) .or. (.not. (exp(re) <= 2.0d0))) 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) <= 0.0) || !(Math.exp(re) <= 2.0)) {
		tmp = Math.exp(re);
	} else {
		tmp = Math.sin(im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (math.exp(re) <= 0.0) or not (math.exp(re) <= 2.0):
		tmp = math.exp(re)
	else:
		tmp = math.sin(im)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((exp(re) <= 0.0) || !(exp(re) <= 2.0))
		tmp = exp(re);
	else
		tmp = sin(im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((exp(re) <= 0.0) || ~((exp(re) <= 2.0)))
		tmp = exp(re);
	else
		tmp = sin(im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 2.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 2\right):\\
\;\;\;\;e^{re}\\

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


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

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity76.7%

        \[\leadsto e^{\color{blue}{1 \cdot \log \left(e^{re} \cdot \sin im\right)}} \]
      3. exp-prod76.7%

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod50.0%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp50.0%

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

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 76.7%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity76.7%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-176.7%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp76.7%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity76.7%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr76.7%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity76.7%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified76.7%

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

    if 0.0 < (exp.f64 re) < 2

    1. Initial program 100.0%

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

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

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

Alternative 5: 62.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 0.999998 \lor \neg \left(e^{re} \leq 1.005\right):\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= (exp re) 0.999998) (not (<= (exp re) 1.005)))
   (exp re)
   (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
	double tmp;
	if ((exp(re) <= 0.999998) || !(exp(re) <= 1.005)) {
		tmp = exp(re);
	} else {
		tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
	}
	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.999998d0) .or. (.not. (exp(re) <= 1.005d0))) then
        tmp = exp(re)
    else
        tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((Math.exp(re) <= 0.999998) || !(Math.exp(re) <= 1.005)) {
		tmp = Math.exp(re);
	} else {
		tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (math.exp(re) <= 0.999998) or not (math.exp(re) <= 1.005):
		tmp = math.exp(re)
	else:
		tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((exp(re) <= 0.999998) || !(exp(re) <= 1.005))
		tmp = exp(re);
	else
		tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((exp(re) <= 0.999998) || ~((exp(re) <= 1.005)))
		tmp = exp(re);
	else
		tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.999998], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.005]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.999998 \lor \neg \left(e^{re} \leq 1.005\right):\\
\;\;\;\;e^{re}\\

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


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

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity77.3%

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

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod51.2%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp51.2%

        \[\leadsto {e}^{\left(\color{blue}{re} + \log \sin im\right)} \]
    4. Applied egg-rr51.2%

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 75.3%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity75.3%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-175.3%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp75.3%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity75.3%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr75.3%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity75.3%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified75.3%

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

    if 0.999998000000000054 < (exp.f64 re) < 1.0049999999999999

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 6: 95.1% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.6 \lor \neg \left(re \leq 140\right) \land re \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -1.6000000000000001 or 140 < re < 1.01999999999999991e103

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity93.3%

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

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod52.0%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp52.0%

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

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 93.3%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity93.3%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-193.3%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp93.3%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity93.3%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr93.3%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity93.3%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified93.3%

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

    if -1.6000000000000001 < re < 140 or 1.01999999999999991e103 < re

    1. Initial program 100.0%

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

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

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

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

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

Alternative 7: 86.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -80 \lor \neg \left(re \leq 205\right):\\
\;\;\;\;e^{re}\\

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


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

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity77.4%

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

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod50.4%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp50.4%

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

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 77.4%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity77.4%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-177.4%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp77.4%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity77.4%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr77.4%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity77.4%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified77.4%

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

    if -80 < re < 205

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -80 \lor \neg \left(re \leq 205\right):\\ \;\;\;\;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 8: 40.1% accurate, 13.5× speedup?

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

\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\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 70.6%

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

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

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

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

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

Alternative 9: 32.9% accurate, 14.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.3 \cdot 10^{+86}:\\
\;\;\;\;im \cdot \left(re + 1\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if 1.2999999999999999e86 < re

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity48.8%

        \[\leadsto e^{\color{blue}{1 \cdot \log \left(e^{re} \cdot \sin im\right)}} \]
      3. exp-prod48.8%

        \[\leadsto \color{blue}{{\left(e^{1}\right)}^{\log \left(e^{re} \cdot \sin im\right)}} \]
      4. exp-1-e48.8%

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod48.8%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp48.8%

        \[\leadsto {e}^{\left(\color{blue}{re} + \log \sin im\right)} \]
    4. Applied egg-rr48.8%

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 48.8%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Taylor expanded in re around 0 39.8%

      \[\leadsto \color{blue}{1 + re \cdot \left(\log e + 0.5 \cdot \left(re \cdot {\log e}^{2}\right)\right)} \]
    7. Step-by-step derivation
      1. log-E39.8%

        \[\leadsto 1 + re \cdot \left(\color{blue}{1} + 0.5 \cdot \left(re \cdot {\log e}^{2}\right)\right) \]
      2. associate-*r*39.8%

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

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

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

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

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

        \[\leadsto 1 + re \cdot \left(1 + \color{blue}{\frac{1}{2}} \cdot \left(re \cdot 1\right)\right) \]
      2. *-rgt-identity39.8%

        \[\leadsto 1 + re \cdot \left(1 + \frac{1}{2} \cdot \color{blue}{re}\right) \]
      3. associate-/r/39.8%

        \[\leadsto 1 + re \cdot \left(1 + \color{blue}{\frac{1}{\frac{2}{re}}}\right) \]
      4. clear-num39.8%

        \[\leadsto 1 + re \cdot \left(1 + \color{blue}{\frac{re}{2}}\right) \]
    10. Applied egg-rr39.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.3 \cdot 10^{+86}:\\ \;\;\;\;im \cdot \left(re + 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + re \cdot \left(1 + \frac{re}{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 37.4% 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 63.6%

    \[\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. *-commutative63.6%

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

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

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

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

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

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

Alternative 11: 27.7% accurate, 25.3× speedup?

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\sin im} \]
    4. Taylor expanded in im around 0 35.3%

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

    if 420 < im

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity62.1%

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

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod52.7%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp52.7%

        \[\leadsto {e}^{\left(\color{blue}{re} + \log \sin im\right)} \]
    4. Applied egg-rr52.7%

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 38.3%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Taylor expanded in re around 0 7.4%

      \[\leadsto \color{blue}{1 + re \cdot \log e} \]
    7. Step-by-step derivation
      1. log-E7.4%

        \[\leadsto 1 + re \cdot \color{blue}{1} \]
      2. *-rgt-identity7.4%

        \[\leadsto 1 + \color{blue}{re} \]
      3. +-commutative7.4%

        \[\leadsto \color{blue}{re + 1} \]
    8. Simplified7.4%

      \[\leadsto \color{blue}{re + 1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 27.7% accurate, 33.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1:\\ \;\;\;\;im\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= im 1.0) im 1.0))
double code(double re, double im) {
	double tmp;
	if (im <= 1.0) {
		tmp = im;
	} else {
		tmp = 1.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.0d0) then
        tmp = im
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.0) {
		tmp = im;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.0:
		tmp = im
	else:
		tmp = 1.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.0)
		tmp = im;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.0)
		tmp = im;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.0], im, 1.0]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;1\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\sin im} \]
    4. Taylor expanded in im around 0 35.3%

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

    if 1 < im

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
      2. *-un-lft-identity62.1%

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

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

        \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
      5. log-prod52.7%

        \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
      6. add-log-exp52.7%

        \[\leadsto {e}^{\left(\color{blue}{re} + \log \sin im\right)} \]
    4. Applied egg-rr52.7%

      \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
    5. Taylor expanded in re around inf 38.3%

      \[\leadsto {e}^{\color{blue}{re}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity38.3%

        \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
      2. e-exp-138.3%

        \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
      3. pow-exp38.3%

        \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
      4. *-un-lft-identity38.3%

        \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
    7. Applied egg-rr38.3%

      \[\leadsto \color{blue}{1 \cdot e^{re}} \]
    8. Step-by-step derivation
      1. *-lft-identity38.3%

        \[\leadsto \color{blue}{e^{re}} \]
    9. Simplified38.3%

      \[\leadsto \color{blue}{e^{re}} \]
    10. Taylor expanded in re around 0 7.2%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 29.9% 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 55.5%

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

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

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

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

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

Alternative 14: 5.1% accurate, 203.0× speedup?

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

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

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

      \[\leadsto \color{blue}{e^{\log \left(e^{re} \cdot \sin im\right)}} \]
    2. *-un-lft-identity60.2%

      \[\leadsto e^{\color{blue}{1 \cdot \log \left(e^{re} \cdot \sin im\right)}} \]
    3. exp-prod60.2%

      \[\leadsto \color{blue}{{\left(e^{1}\right)}^{\log \left(e^{re} \cdot \sin im\right)}} \]
    4. exp-1-e60.2%

      \[\leadsto {\color{blue}{e}}^{\log \left(e^{re} \cdot \sin im\right)} \]
    5. log-prod48.1%

      \[\leadsto {e}^{\color{blue}{\left(\log \left(e^{re}\right) + \log \sin im\right)}} \]
    6. add-log-exp48.1%

      \[\leadsto {e}^{\left(\color{blue}{re} + \log \sin im\right)} \]
  4. Applied egg-rr48.1%

    \[\leadsto \color{blue}{{e}^{\left(re + \log \sin im\right)}} \]
  5. Taylor expanded in re around inf 38.8%

    \[\leadsto {e}^{\color{blue}{re}} \]
  6. Step-by-step derivation
    1. *-un-lft-identity38.8%

      \[\leadsto \color{blue}{1 \cdot {e}^{re}} \]
    2. e-exp-138.8%

      \[\leadsto 1 \cdot {\color{blue}{\left(e^{1}\right)}}^{re} \]
    3. pow-exp38.8%

      \[\leadsto 1 \cdot \color{blue}{e^{1 \cdot re}} \]
    4. *-un-lft-identity38.8%

      \[\leadsto 1 \cdot e^{\color{blue}{re}} \]
  7. Applied egg-rr38.8%

    \[\leadsto \color{blue}{1 \cdot e^{re}} \]
  8. Step-by-step derivation
    1. *-lft-identity38.8%

      \[\leadsto \color{blue}{e^{re}} \]
  9. Simplified38.8%

    \[\leadsto \color{blue}{e^{re}} \]
  10. Taylor expanded in re around 0 5.2%

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

Reproduce

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