math.exp on complex, imaginary part

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 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: 89.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right)\\ t_1 := e^{re} \cdot \sin im\\ t_2 := \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right)\\ t_3 := e^{re} \cdot im\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+185}:\\ \;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im \cdot im, -0.08333333333333333, 0.5\right)\\ \mathbf{elif}\;t\_1 \leq -0.005:\\ \;\;\;\;\sin im \cdot \mathsf{fma}\left(re, t\_2, 1\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-128}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 1:\\ \;\;\;\;\sin im \cdot \frac{\mathsf{fma}\left(t\_0, t\_0, -1\right)}{\mathsf{fma}\left(re, t\_2, -1\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (fma (fma re 0.16666666666666666 0.5) (* re re) re))
        (t_1 (* (exp re) (sin im)))
        (t_2 (fma re (fma re 0.16666666666666666 0.5) 1.0))
        (t_3 (* (exp re) im)))
   (if (<= t_1 -1e+185)
     (* (* im (* re re)) (fma (* im im) -0.08333333333333333 0.5))
     (if (<= t_1 -0.005)
       (* (sin im) (fma re t_2 1.0))
       (if (<= t_1 1e-128)
         t_3
         (if (<= t_1 1.0)
           (* (sin im) (/ (fma t_0 t_0 -1.0) (fma re t_2 -1.0)))
           t_3))))))
double code(double re, double im) {
	double t_0 = fma(fma(re, 0.16666666666666666, 0.5), (re * re), re);
	double t_1 = exp(re) * sin(im);
	double t_2 = fma(re, fma(re, 0.16666666666666666, 0.5), 1.0);
	double t_3 = exp(re) * im;
	double tmp;
	if (t_1 <= -1e+185) {
		tmp = (im * (re * re)) * fma((im * im), -0.08333333333333333, 0.5);
	} else if (t_1 <= -0.005) {
		tmp = sin(im) * fma(re, t_2, 1.0);
	} else if (t_1 <= 1e-128) {
		tmp = t_3;
	} else if (t_1 <= 1.0) {
		tmp = sin(im) * (fma(t_0, t_0, -1.0) / fma(re, t_2, -1.0));
	} else {
		tmp = t_3;
	}
	return tmp;
}
function code(re, im)
	t_0 = fma(fma(re, 0.16666666666666666, 0.5), Float64(re * re), re)
	t_1 = Float64(exp(re) * sin(im))
	t_2 = fma(re, fma(re, 0.16666666666666666, 0.5), 1.0)
	t_3 = Float64(exp(re) * im)
	tmp = 0.0
	if (t_1 <= -1e+185)
		tmp = Float64(Float64(im * Float64(re * re)) * fma(Float64(im * im), -0.08333333333333333, 0.5));
	elseif (t_1 <= -0.005)
		tmp = Float64(sin(im) * fma(re, t_2, 1.0));
	elseif (t_1 <= 1e-128)
		tmp = t_3;
	elseif (t_1 <= 1.0)
		tmp = Float64(sin(im) * Float64(fma(t_0, t_0, -1.0) / fma(re, t_2, -1.0)));
	else
		tmp = t_3;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(re * re), $MachinePrecision] + re), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+185], N[(N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.005], N[(N[Sin[im], $MachinePrecision] * N[(re * t$95$2 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-128], t$95$3, If[LessEqual[t$95$1, 1.0], N[(N[Sin[im], $MachinePrecision] * N[(N[(t$95$0 * t$95$0 + -1.0), $MachinePrecision] / N[(re * t$95$2 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right)\\
t_1 := e^{re} \cdot \sin im\\
t_2 := \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right)\\
t_3 := e^{re} \cdot im\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+185}:\\
\;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im \cdot im, -0.08333333333333333, 0.5\right)\\

\mathbf{elif}\;t\_1 \leq -0.005:\\
\;\;\;\;\sin im \cdot \mathsf{fma}\left(re, t\_2, 1\right)\\

\mathbf{elif}\;t\_1 \leq 10^{-128}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;\sin im \cdot \frac{\mathsf{fma}\left(t\_0, t\_0, -1\right)}{\mathsf{fma}\left(re, t\_2, -1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -9.9999999999999998e184

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)} \cdot \sin im \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(1 + \frac{1}{2} \cdot re\right) + 1\right)} \cdot \sin im \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, 1 + \frac{1}{2} \cdot re, 1\right)} \cdot \sin im \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\frac{1}{2} \cdot re + 1}, 1\right) \cdot \sin im \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{re \cdot \frac{1}{2}} + 1, 1\right) \cdot \sin im \]
      5. lower-fma.f6453.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right)} \cdot \sin im \]
    6. Taylor expanded in re around inf

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)} \cdot \sin im \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)} \cdot \sin im \]
      2. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \sin im \]
      3. lower-*.f6453.3

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

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

      \[\leadsto \color{blue}{im \cdot \left(\frac{-1}{12} \cdot \left({im}^{2} \cdot {re}^{2}\right) + \frac{1}{2} \cdot {re}^{2}\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\frac{-1}{12} \cdot \left({im}^{2} \cdot {re}^{2}\right)\right) \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot im} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\frac{-1}{12} \cdot {im}^{2}\right) \cdot {re}^{2}\right)} \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot im \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{\left(\frac{-1}{12} \cdot {im}^{2}\right) \cdot \left({re}^{2} \cdot im\right)} + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot im \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{\left(im \cdot {re}^{2}\right)} + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot im \]
      5. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{12} \cdot {im}^{2}\right) \cdot \left(im \cdot {re}^{2}\right) + \color{blue}{\frac{1}{2} \cdot \left({re}^{2} \cdot im\right)} \]
      6. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{12} \cdot {im}^{2}\right) \cdot \left(im \cdot {re}^{2}\right) + \frac{1}{2} \cdot \color{blue}{\left(im \cdot {re}^{2}\right)} \]
      7. distribute-rgt-outN/A

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right) \cdot \left(\frac{-1}{12} \cdot {im}^{2} + \frac{1}{2}\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right) \cdot \left(\frac{-1}{12} \cdot {im}^{2} + \frac{1}{2}\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot \left(\frac{-1}{12} \cdot {im}^{2} + \frac{1}{2}\right) \]
      10. unpow2N/A

        \[\leadsto \left(im \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \left(\frac{-1}{12} \cdot {im}^{2} + \frac{1}{2}\right) \]
      11. lower-*.f64N/A

        \[\leadsto \left(im \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \left(\frac{-1}{12} \cdot {im}^{2} + \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(im \cdot \left(re \cdot re\right)\right) \cdot \left(\color{blue}{{im}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \]
      13. lower-fma.f64N/A

        \[\leadsto \left(im \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \]
      14. unpow2N/A

        \[\leadsto \left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{-1}{12}, \frac{1}{2}\right) \]
      15. lower-*.f6449.1

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

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

    if -9.9999999999999998e184 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0050000000000000001

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)} \cdot \sin im \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right) + 1\right)} \cdot \sin im \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, 1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right), 1\right)} \cdot \sin im \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right) + 1}, 1\right) \cdot \sin im \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} + \frac{1}{6} \cdot re, 1\right)}, 1\right) \cdot \sin im \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \color{blue}{\frac{1}{6} \cdot re + \frac{1}{2}}, 1\right), 1\right) \cdot \sin im \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \color{blue}{re \cdot \frac{1}{6}} + \frac{1}{2}, 1\right), 1\right) \cdot \sin im \]
      7. lower-fma.f6499.2

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

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

    if -0.0050000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1.00000000000000005e-128 or 1 < (*.f64 (exp.f64 re) (sin.f64 im))

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{im \cdot e^{re}} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
      2. lower-exp.f6494.2

        \[\leadsto im \cdot \color{blue}{e^{re}} \]
    5. Simplified94.2%

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

    if 1.00000000000000005e-128 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)} \cdot \sin im \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right) + 1\right)} \cdot \sin im \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, 1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right), 1\right)} \cdot \sin im \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right) + 1}, 1\right) \cdot \sin im \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} + \frac{1}{6} \cdot re, 1\right)}, 1\right) \cdot \sin im \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \color{blue}{\frac{1}{6} \cdot re + \frac{1}{2}}, 1\right), 1\right) \cdot \sin im \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \color{blue}{re \cdot \frac{1}{6}} + \frac{1}{2}, 1\right), 1\right) \cdot \sin im \]
      7. lower-fma.f6499.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right)} \cdot \sin im \]
    6. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(re \cdot \left(re \cdot \color{blue}{\mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right)} + 1\right) + 1\right) \cdot \sin im \]
      2. lift-fma.f64N/A

        \[\leadsto \left(re \cdot \color{blue}{\mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right)} + 1\right) \cdot \sin im \]
      3. flip-+N/A

        \[\leadsto \color{blue}{\frac{\left(re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right)\right) \cdot \left(re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right)\right) - 1 \cdot 1}{re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right) - 1}} \cdot \sin im \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right)\right) \cdot \left(re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right)\right) - 1 \cdot 1}{re \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{6}, \frac{1}{2}\right), 1\right) - 1}} \cdot \sin im \]
    7. Applied egg-rr99.1%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right), \mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right), -1\right)}{\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), -1\right)}} \cdot \sin im \]
  3. Recombined 4 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im \leq -1 \cdot 10^{+185}:\\ \;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im \cdot im, -0.08333333333333333, 0.5\right)\\ \mathbf{elif}\;e^{re} \cdot \sin im \leq -0.005:\\ \;\;\;\;\sin im \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right)\\ \mathbf{elif}\;e^{re} \cdot \sin im \leq 10^{-128}:\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{elif}\;e^{re} \cdot \sin im \leq 1:\\ \;\;\;\;\sin im \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right), \mathsf{fma}\left(\mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), re \cdot re, re\right), -1\right)}{\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), -1\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{re} \cdot im\\ \end{array} \]
  5. Add Preprocessing

Reproduce

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