math.exp on complex, imaginary part

Percentage Accurate: 100.0% → 100.0%
Time: 6.4s
Alternatives: 10
Speedup: 0.9×

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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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}

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 10 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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, 0.9× speedup?

\[\begin{array}{l} \\ \sqrt{e^{re + re}} \cdot \sin im \end{array} \]
(FPCore (re im) :precision binary64 (* (sqrt (exp (+ re re))) (sin im)))
double code(double re, double im) {
	return sqrt(exp((re + re))) * sin(im);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sqrt(exp((re + re))) * sin(im)
end function
public static double code(double re, double im) {
	return Math.sqrt(Math.exp((re + re))) * Math.sin(im);
}
def code(re, im):
	return math.sqrt(math.exp((re + re))) * math.sin(im)
function code(re, im)
	return Float64(sqrt(exp(Float64(re + re))) * sin(im))
end
function tmp = code(re, im)
	tmp = sqrt(exp((re + re))) * sin(im);
end
code[re_, im_] := N[(N[Sqrt[N[Exp[N[(re + re), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[e^{re} \cdot \sin im \]
  2. Applied rewrites99.9%

    \[\leadsto \color{blue}{\sqrt{e^{re + re}}} \cdot \sin im \]
  3. Add Preprocessing

Alternative 2: 99.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{re} \cdot \sin im\\ t_1 := e^{re} \cdot im\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\ \mathbf{elif}\;t\_0 \leq -0.005:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(re, 2, 1\right)} \cdot \sin im\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-44}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin im\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (exp re) (sin im))) (t_1 (* (exp re) im)))
   (if (<= t_0 (- INFINITY))
     (* (exp re) (* (fma (* im -0.16666666666666666) im 1.0) im))
     (if (<= t_0 -0.005)
       (* (sqrt (fma re 2.0 1.0)) (sin im))
       (if (<= t_0 2e-44) t_1 (if (<= t_0 1.0) (sin im) t_1))))))
double code(double re, double im) {
	double t_0 = exp(re) * sin(im);
	double t_1 = exp(re) * im;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = exp(re) * (fma((im * -0.16666666666666666), im, 1.0) * im);
	} else if (t_0 <= -0.005) {
		tmp = sqrt(fma(re, 2.0, 1.0)) * sin(im);
	} else if (t_0 <= 2e-44) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = sin(im);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(exp(re) * sin(im))
	t_1 = Float64(exp(re) * im)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(exp(re) * Float64(fma(Float64(im * -0.16666666666666666), im, 1.0) * im));
	elseif (t_0 <= -0.005)
		tmp = Float64(sqrt(fma(re, 2.0, 1.0)) * sin(im));
	elseif (t_0 <= 2e-44)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = sin(im);
	else
		tmp = t_1;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[Exp[re], $MachinePrecision] * N[(N[(N[(im * -0.16666666666666666), $MachinePrecision] * im + 1.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.005], N[(N[Sqrt[N[(re * 2.0 + 1.0), $MachinePrecision]], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-44], t$95$1, If[LessEqual[t$95$0, 1.0], N[Sin[im], $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
t_1 := e^{re} \cdot im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin im\\

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto e^{re} \cdot \color{blue}{\left(im \cdot \left(1 + -0.16666666666666666 \cdot {im}^{2}\right)\right)} \]
    4. Applied rewrites61.0%

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

    if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0050000000000000001

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Applied rewrites99.9%

      \[\leadsto \color{blue}{\sqrt{e^{re + re}}} \cdot \sin im \]
    3. Taylor expanded in re around 0

      \[\leadsto \sqrt{\color{blue}{1 + 2 \cdot re}} \cdot \sin im \]
    4. Applied rewrites49.6%

      \[\leadsto \sqrt{\color{blue}{1 + 2 \cdot re}} \cdot \sin im \]
    5. Applied rewrites49.6%

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

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

    1. Initial program 100.0%

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

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    3. Applied rewrites69.1%

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

    if 1.99999999999999991e-44 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\sin im} \]
    3. Applied rewrites50.1%

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

Alternative 3: 93.3% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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

Alternative 4: 93.3% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
t_1 := e^{re} \cdot im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\

\mathbf{elif}\;t\_0 \leq -0.005:\\
\;\;\;\;\left(1 + re\right) \cdot \sin im\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin im\\

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto e^{re} \cdot \color{blue}{\left(im \cdot \left(1 + -0.16666666666666666 \cdot {im}^{2}\right)\right)} \]
    4. Applied rewrites61.0%

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

    if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0050000000000000001

    1. Initial program 100.0%

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

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

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

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

    1. Initial program 100.0%

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

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    3. Applied rewrites69.1%

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

    if 1.99999999999999991e-44 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\sin im} \]
    3. Applied rewrites50.1%

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

Alternative 5: 93.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
t_1 := e^{re} \cdot im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\

\mathbf{elif}\;t\_0 \leq -0.005:\\
\;\;\;\;\sin im\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin im\\

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto e^{re} \cdot \color{blue}{\left(im \cdot \left(1 + -0.16666666666666666 \cdot {im}^{2}\right)\right)} \]
    4. Applied rewrites61.0%

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

    if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0050000000000000001 or 1.99999999999999991e-44 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\sin im} \]
    3. Applied rewrites50.1%

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

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

    1. Initial program 100.0%

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

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    3. Applied rewrites69.1%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 69.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im \leq -0.005:\\ \;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;e^{re} \cdot im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (* (exp re) (sin im)) -0.005)
   (* (exp re) (* (fma (* im -0.16666666666666666) im 1.0) im))
   (* (exp re) im)))
double code(double re, double im) {
	double tmp;
	if ((exp(re) * sin(im)) <= -0.005) {
		tmp = exp(re) * (fma((im * -0.16666666666666666), im, 1.0) * im);
	} else {
		tmp = exp(re) * im;
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (Float64(exp(re) * sin(im)) <= -0.005)
		tmp = Float64(exp(re) * Float64(fma(Float64(im * -0.16666666666666666), im, 1.0) * im));
	else
		tmp = Float64(exp(re) * im);
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[Exp[re], $MachinePrecision] * N[(N[(N[(im * -0.16666666666666666), $MachinePrecision] * im + 1.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin im \leq -0.005:\\
\;\;\;\;e^{re} \cdot \left(\mathsf{fma}\left(im \cdot -0.16666666666666666, im, 1\right) \cdot im\right)\\

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto e^{re} \cdot \color{blue}{\left(im \cdot \left(1 + -0.16666666666666666 \cdot {im}^{2}\right)\right)} \]
    4. Applied rewrites61.0%

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

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

    1. Initial program 100.0%

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

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
    3. Applied rewrites69.1%

      \[\leadsto e^{re} \cdot \color{blue}{im} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 69.1% accurate, 3.3× speedup?

\[\begin{array}{l} \\ e^{re} \cdot im \end{array} \]
(FPCore (re im) :precision binary64 (* (exp re) im))
double code(double re, double im) {
	return exp(re) * im;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

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

    \[\leadsto e^{re} \cdot \color{blue}{im} \]
  3. Applied rewrites69.1%

    \[\leadsto e^{re} \cdot \color{blue}{im} \]
  4. Add Preprocessing

Alternative 8: 33.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im \leq 2 \cdot 10^{-59}:\\ \;\;\;\;\frac{im}{1 + -1 \cdot re}\\ \mathbf{else}:\\ \;\;\;\;im + im \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (* (exp re) (sin im)) 2e-59)
   (/ im (+ 1.0 (* -1.0 re)))
   (+ im (* im re))))
double code(double re, double im) {
	double tmp;
	if ((exp(re) * sin(im)) <= 2e-59) {
		tmp = im / (1.0 + (-1.0 * re));
	} else {
		tmp = im + (im * re);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((exp(re) * sin(im)) <= 2d-59) then
        tmp = im / (1.0d0 + ((-1.0d0) * re))
    else
        tmp = im + (im * re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((Math.exp(re) * Math.sin(im)) <= 2e-59) {
		tmp = im / (1.0 + (-1.0 * re));
	} else {
		tmp = im + (im * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (math.exp(re) * math.sin(im)) <= 2e-59:
		tmp = im / (1.0 + (-1.0 * re))
	else:
		tmp = im + (im * re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (Float64(exp(re) * sin(im)) <= 2e-59)
		tmp = Float64(im / Float64(1.0 + Float64(-1.0 * re)));
	else
		tmp = Float64(im + Float64(im * re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((exp(re) * sin(im)) <= 2e-59)
		tmp = im / (1.0 + (-1.0 * re));
	else
		tmp = im + (im * re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], 2e-59], N[(im / N[(1.0 + N[(-1.0 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im + N[(im * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin im \leq 2 \cdot 10^{-59}:\\
\;\;\;\;\frac{im}{1 + -1 \cdot re}\\

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


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

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Applied rewrites100.0%

      \[\leadsto \color{blue}{\frac{1}{e^{-re}}} \cdot \sin im \]
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\frac{im}{e^{\mathsf{neg}\left(re\right)}}} \]
    4. Applied rewrites69.1%

      \[\leadsto \color{blue}{\frac{im}{e^{-re}}} \]
    5. Taylor expanded in re around 0

      \[\leadsto \frac{im}{1 + \color{blue}{-1 \cdot re}} \]
    6. Applied rewrites32.3%

      \[\leadsto \frac{im}{1 + \color{blue}{-1 \cdot re}} \]

    if 2.0000000000000001e-59 < (*.f64 (exp.f64 re) (sin.f64 im))

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Applied rewrites100.0%

      \[\leadsto \color{blue}{\frac{1}{e^{-re}}} \cdot \sin im \]
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\frac{im}{e^{\mathsf{neg}\left(re\right)}}} \]
    4. Applied rewrites69.1%

      \[\leadsto \color{blue}{\frac{im}{e^{-re}}} \]
    5. Taylor expanded in re around 0

      \[\leadsto im + \color{blue}{im \cdot re} \]
    6. Applied rewrites29.1%

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

Alternative 9: 29.1% accurate, 6.9× speedup?

\[\begin{array}{l} \\ im + im \cdot re \end{array} \]
(FPCore (re im) :precision binary64 (+ im (* im re)))
double code(double re, double im) {
	return im + (im * re);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = im + (im * re)
end function
public static double code(double re, double im) {
	return im + (im * re);
}
def code(re, im):
	return im + (im * re)
function code(re, im)
	return Float64(im + Float64(im * re))
end
function tmp = code(re, im)
	tmp = im + (im * re);
end
code[re_, im_] := N[(im + N[(im * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[e^{re} \cdot \sin im \]
  2. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1}{e^{-re}}} \cdot \sin im \]
  3. Taylor expanded in im around 0

    \[\leadsto \color{blue}{\frac{im}{e^{\mathsf{neg}\left(re\right)}}} \]
  4. Applied rewrites69.1%

    \[\leadsto \color{blue}{\frac{im}{e^{-re}}} \]
  5. Taylor expanded in re around 0

    \[\leadsto im + \color{blue}{im \cdot re} \]
  6. Applied rewrites29.1%

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

Alternative 10: 26.2% accurate, 45.8× speedup?

\[\begin{array}{l} \\ im \end{array} \]
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
	return im;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    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. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1}{e^{-re}}} \cdot \sin im \]
  3. Taylor expanded in im around 0

    \[\leadsto \color{blue}{\frac{im}{e^{\mathsf{neg}\left(re\right)}}} \]
  4. Applied rewrites69.1%

    \[\leadsto \color{blue}{\frac{im}{e^{-re}}} \]
  5. Taylor expanded in re around 0

    \[\leadsto im \]
  6. Applied rewrites26.2%

    \[\leadsto im \]
  7. Add Preprocessing

Reproduce

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