
(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]
e^{re} \cdot \sin im
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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]
e^{re} \cdot \sin im
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs im) (exp re)))
(t_1 (sin (fabs im)))
(t_2 (* (+ 1 re) t_1))
(t_3 (* (exp re) t_1)))
(*
(copysign 1 im)
(if (<=
t_3
-999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448)
(*
(+ 1 (* re (+ 1 (* re (+ 1/2 (* 1/6 re))))))
(* (fabs im) (+ 1 (* -1/6 (pow (fabs im) 2)))))
(if (<= t_3 -3602879701896397/36028797018963968)
t_2
(if (<= t_3 0) t_0 (if (<= t_3 1) t_2 t_0)))))))double code(double re, double im) {
double t_0 = fabs(im) * exp(re);
double t_1 = sin(fabs(im));
double t_2 = (1.0 + re) * t_1;
double t_3 = exp(re) * t_1;
double tmp;
if (t_3 <= -1e+168) {
tmp = (1.0 + (re * (1.0 + (re * (0.5 + (0.16666666666666666 * re)))))) * (fabs(im) * (1.0 + (-0.16666666666666666 * pow(fabs(im), 2.0))));
} else if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = t_0;
} else if (t_3 <= 1.0) {
tmp = t_2;
} else {
tmp = t_0;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.abs(im) * Math.exp(re);
double t_1 = Math.sin(Math.abs(im));
double t_2 = (1.0 + re) * t_1;
double t_3 = Math.exp(re) * t_1;
double tmp;
if (t_3 <= -1e+168) {
tmp = (1.0 + (re * (1.0 + (re * (0.5 + (0.16666666666666666 * re)))))) * (Math.abs(im) * (1.0 + (-0.16666666666666666 * Math.pow(Math.abs(im), 2.0))));
} else if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = t_0;
} else if (t_3 <= 1.0) {
tmp = t_2;
} else {
tmp = t_0;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.fabs(im) * math.exp(re) t_1 = math.sin(math.fabs(im)) t_2 = (1.0 + re) * t_1 t_3 = math.exp(re) * t_1 tmp = 0 if t_3 <= -1e+168: tmp = (1.0 + (re * (1.0 + (re * (0.5 + (0.16666666666666666 * re)))))) * (math.fabs(im) * (1.0 + (-0.16666666666666666 * math.pow(math.fabs(im), 2.0)))) elif t_3 <= -0.1: tmp = t_2 elif t_3 <= 0.0: tmp = t_0 elif t_3 <= 1.0: tmp = t_2 else: tmp = t_0 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(abs(im) * exp(re)) t_1 = sin(abs(im)) t_2 = Float64(Float64(1.0 + re) * t_1) t_3 = Float64(exp(re) * t_1) tmp = 0.0 if (t_3 <= -1e+168) tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(0.16666666666666666 * re)))))) * Float64(abs(im) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(im) ^ 2.0))))); elseif (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.0) tmp = t_0; elseif (t_3 <= 1.0) tmp = t_2; else tmp = t_0; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = abs(im) * exp(re); t_1 = sin(abs(im)); t_2 = (1.0 + re) * t_1; t_3 = exp(re) * t_1; tmp = 0.0; if (t_3 <= -1e+168) tmp = (1.0 + (re * (1.0 + (re * (0.5 + (0.16666666666666666 * re)))))) * (abs(im) * (1.0 + (-0.16666666666666666 * (abs(im) ^ 2.0)))); elseif (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.0) tmp = t_0; elseif (t_3 <= 1.0) tmp = t_2; else tmp = t_0; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(1 + re), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Exp[re], $MachinePrecision] * t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448], N[(N[(1 + N[(re * N[(1 + N[(re * N[(1/2 + N[(1/6 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[im], $MachinePrecision] * N[(1 + N[(-1/6 * N[Power[N[Abs[im], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 0], t$95$0, If[LessEqual[t$95$3, 1], t$95$2, t$95$0]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot e^{re}\\
t_1 := \sin \left(\left|im\right|\right)\\
t_2 := \left(1 + re\right) \cdot t\_1\\
t_3 := e^{re} \cdot t\_1\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right) \cdot \left(\left|im\right| \cdot \left(1 + \frac{-1}{6} \cdot {\left(\left|im\right|\right)}^{2}\right)\right)\\
\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_3 \leq 1:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -9.9999999999999993e167Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6467.8%
Applied rewrites67.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6440.0%
Applied rewrites40.0%
if -9.9999999999999993e167 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.10000000000000001 or 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6451.8%
Applied rewrites51.8%
if -0.10000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0 or 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs im) (exp re)))
(t_1 (sin (fabs im)))
(t_2 (* (exp re) t_1))
(t_3 (* (+ 1 re) t_1)))
(*
(copysign 1 im)
(if (<=
t_2
-999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448)
(*
(- (fabs im) (* (* (* (fabs im) (fabs im)) 1/6) (fabs im)))
(- (* (- (* 1/2 re) -1) re) -1))
(if (<= t_2 -3602879701896397/36028797018963968)
t_3
(if (<= t_2 0) t_0 (if (<= t_2 1) t_3 t_0)))))))double code(double re, double im) {
double t_0 = fabs(im) * exp(re);
double t_1 = sin(fabs(im));
double t_2 = exp(re) * t_1;
double t_3 = (1.0 + re) * t_1;
double tmp;
if (t_2 <= -1e+168) {
tmp = (fabs(im) - (((fabs(im) * fabs(im)) * 0.16666666666666666) * fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= -0.1) {
tmp = t_3;
} else if (t_2 <= 0.0) {
tmp = t_0;
} else if (t_2 <= 1.0) {
tmp = t_3;
} else {
tmp = t_0;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.abs(im) * Math.exp(re);
double t_1 = Math.sin(Math.abs(im));
double t_2 = Math.exp(re) * t_1;
double t_3 = (1.0 + re) * t_1;
double tmp;
if (t_2 <= -1e+168) {
tmp = (Math.abs(im) - (((Math.abs(im) * Math.abs(im)) * 0.16666666666666666) * Math.abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= -0.1) {
tmp = t_3;
} else if (t_2 <= 0.0) {
tmp = t_0;
} else if (t_2 <= 1.0) {
tmp = t_3;
} else {
tmp = t_0;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.fabs(im) * math.exp(re) t_1 = math.sin(math.fabs(im)) t_2 = math.exp(re) * t_1 t_3 = (1.0 + re) * t_1 tmp = 0 if t_2 <= -1e+168: tmp = (math.fabs(im) - (((math.fabs(im) * math.fabs(im)) * 0.16666666666666666) * math.fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0) elif t_2 <= -0.1: tmp = t_3 elif t_2 <= 0.0: tmp = t_0 elif t_2 <= 1.0: tmp = t_3 else: tmp = t_0 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(abs(im) * exp(re)) t_1 = sin(abs(im)) t_2 = Float64(exp(re) * t_1) t_3 = Float64(Float64(1.0 + re) * t_1) tmp = 0.0 if (t_2 <= -1e+168) tmp = Float64(Float64(abs(im) - Float64(Float64(Float64(abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * Float64(Float64(Float64(Float64(0.5 * re) - -1.0) * re) - -1.0)); elseif (t_2 <= -0.1) tmp = t_3; elseif (t_2 <= 0.0) tmp = t_0; elseif (t_2 <= 1.0) tmp = t_3; else tmp = t_0; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = abs(im) * exp(re); t_1 = sin(abs(im)); t_2 = exp(re) * t_1; t_3 = (1.0 + re) * t_1; tmp = 0.0; if (t_2 <= -1e+168) tmp = (abs(im) - (((abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0); elseif (t_2 <= -0.1) tmp = t_3; elseif (t_2 <= 0.0) tmp = t_0; elseif (t_2 <= 1.0) tmp = t_3; else tmp = t_0; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[re], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(1 + re), $MachinePrecision] * t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448], N[(N[(N[Abs[im], $MachinePrecision] - N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * 1/6), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(1/2 * re), $MachinePrecision] - -1), $MachinePrecision] * re), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$3, If[LessEqual[t$95$2, 0], t$95$0, If[LessEqual[t$95$2, 1], t$95$3, t$95$0]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot e^{re}\\
t_1 := \sin \left(\left|im\right|\right)\\
t_2 := e^{re} \cdot t\_1\\
t_3 := \left(1 + re\right) \cdot t\_1\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448:\\
\;\;\;\;\left(\left|im\right| - \left(\left(\left|im\right| \cdot \left|im\right|\right) \cdot \frac{1}{6}\right) \cdot \left|im\right|\right) \cdot \left(\left(\frac{1}{2} \cdot re - -1\right) \cdot re - -1\right)\\
\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -9.9999999999999993e167Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.9%
Applied rewrites38.0%
if -9.9999999999999993e167 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.10000000000000001 or 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6451.8%
Applied rewrites51.8%
if -0.10000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0 or 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs im) (exp re)))
(t_1 (sin (fabs im)))
(t_2 (* (exp re) t_1)))
(*
(copysign 1 im)
(if (<=
t_2
-999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448)
(*
(- (fabs im) (* (* (* (fabs im) (fabs im)) 1/6) (fabs im)))
(- (* (- (* 1/2 re) -1) re) -1))
(if (<= t_2 -3602879701896397/36028797018963968)
t_1
(if (<= t_2 4835703278458517/2417851639229258349412352)
t_0
(if (<= t_2 1) t_1 t_0)))))))double code(double re, double im) {
double t_0 = fabs(im) * exp(re);
double t_1 = sin(fabs(im));
double t_2 = exp(re) * t_1;
double tmp;
if (t_2 <= -1e+168) {
tmp = (fabs(im) - (((fabs(im) * fabs(im)) * 0.16666666666666666) * fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 2e-9) {
tmp = t_0;
} else if (t_2 <= 1.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.abs(im) * Math.exp(re);
double t_1 = Math.sin(Math.abs(im));
double t_2 = Math.exp(re) * t_1;
double tmp;
if (t_2 <= -1e+168) {
tmp = (Math.abs(im) - (((Math.abs(im) * Math.abs(im)) * 0.16666666666666666) * Math.abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 2e-9) {
tmp = t_0;
} else if (t_2 <= 1.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.fabs(im) * math.exp(re) t_1 = math.sin(math.fabs(im)) t_2 = math.exp(re) * t_1 tmp = 0 if t_2 <= -1e+168: tmp = (math.fabs(im) - (((math.fabs(im) * math.fabs(im)) * 0.16666666666666666) * math.fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0) elif t_2 <= -0.1: tmp = t_1 elif t_2 <= 2e-9: tmp = t_0 elif t_2 <= 1.0: tmp = t_1 else: tmp = t_0 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(abs(im) * exp(re)) t_1 = sin(abs(im)) t_2 = Float64(exp(re) * t_1) tmp = 0.0 if (t_2 <= -1e+168) tmp = Float64(Float64(abs(im) - Float64(Float64(Float64(abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * Float64(Float64(Float64(Float64(0.5 * re) - -1.0) * re) - -1.0)); elseif (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 2e-9) tmp = t_0; elseif (t_2 <= 1.0) tmp = t_1; else tmp = t_0; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = abs(im) * exp(re); t_1 = sin(abs(im)); t_2 = exp(re) * t_1; tmp = 0.0; if (t_2 <= -1e+168) tmp = (abs(im) - (((abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0); elseif (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 2e-9) tmp = t_0; elseif (t_2 <= 1.0) tmp = t_1; else tmp = t_0; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[re], $MachinePrecision] * t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448], N[(N[(N[Abs[im], $MachinePrecision] - N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * 1/6), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(1/2 * re), $MachinePrecision] - -1), $MachinePrecision] * re), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$1, If[LessEqual[t$95$2, 4835703278458517/2417851639229258349412352], t$95$0, If[LessEqual[t$95$2, 1], t$95$1, t$95$0]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot e^{re}\\
t_1 := \sin \left(\left|im\right|\right)\\
t_2 := e^{re} \cdot t\_1\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448:\\
\;\;\;\;\left(\left|im\right| - \left(\left(\left|im\right| \cdot \left|im\right|\right) \cdot \frac{1}{6}\right) \cdot \left|im\right|\right) \cdot \left(\left(\frac{1}{2} \cdot re - -1\right) \cdot re - -1\right)\\
\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq \frac{4835703278458517}{2417851639229258349412352}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -9.9999999999999993e167Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.9%
Applied rewrites38.0%
if -9.9999999999999993e167 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.10000000000000001 or 2.0000000000000001e-9 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
if -0.10000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 2.0000000000000001e-9 or 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* (- (* 1/6 re) -1/2) re) re)))
(if (<= re -540)
(* im (exp re))
(if (<=
re
13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160)
(*
(+ 1 (/ (- (* t_0 t_0) (* re re)) (* re (- (* 1/2 re) 1))))
(sin im))
(* (+ 1 (* re (+ 1 (* 1/2 re)))) (sin im))))))double code(double re, double im) {
double t_0 = (((0.16666666666666666 * re) - -0.5) * re) * re;
double tmp;
if (re <= -540.0) {
tmp = im * exp(re);
} else if (re <= 1.35e+154) {
tmp = (1.0 + (((t_0 * t_0) - (re * re)) / (re * ((0.5 * re) - 1.0)))) * sin(im);
} else {
tmp = (1.0 + (re * (1.0 + (0.5 * re)))) * sin(im);
}
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) :: t_0
real(8) :: tmp
t_0 = (((0.16666666666666666d0 * re) - (-0.5d0)) * re) * re
if (re <= (-540.0d0)) then
tmp = im * exp(re)
else if (re <= 1.35d+154) then
tmp = (1.0d0 + (((t_0 * t_0) - (re * re)) / (re * ((0.5d0 * re) - 1.0d0)))) * sin(im)
else
tmp = (1.0d0 + (re * (1.0d0 + (0.5d0 * re)))) * sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (((0.16666666666666666 * re) - -0.5) * re) * re;
double tmp;
if (re <= -540.0) {
tmp = im * Math.exp(re);
} else if (re <= 1.35e+154) {
tmp = (1.0 + (((t_0 * t_0) - (re * re)) / (re * ((0.5 * re) - 1.0)))) * Math.sin(im);
} else {
tmp = (1.0 + (re * (1.0 + (0.5 * re)))) * Math.sin(im);
}
return tmp;
}
def code(re, im): t_0 = (((0.16666666666666666 * re) - -0.5) * re) * re tmp = 0 if re <= -540.0: tmp = im * math.exp(re) elif re <= 1.35e+154: tmp = (1.0 + (((t_0 * t_0) - (re * re)) / (re * ((0.5 * re) - 1.0)))) * math.sin(im) else: tmp = (1.0 + (re * (1.0 + (0.5 * re)))) * math.sin(im) return tmp
function code(re, im) t_0 = Float64(Float64(Float64(Float64(0.16666666666666666 * re) - -0.5) * re) * re) tmp = 0.0 if (re <= -540.0) tmp = Float64(im * exp(re)); elseif (re <= 1.35e+154) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(t_0 * t_0) - Float64(re * re)) / Float64(re * Float64(Float64(0.5 * re) - 1.0)))) * sin(im)); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(0.5 * re)))) * sin(im)); end return tmp end
function tmp_2 = code(re, im) t_0 = (((0.16666666666666666 * re) - -0.5) * re) * re; tmp = 0.0; if (re <= -540.0) tmp = im * exp(re); elseif (re <= 1.35e+154) tmp = (1.0 + (((t_0 * t_0) - (re * re)) / (re * ((0.5 * re) - 1.0)))) * sin(im); else tmp = (1.0 + (re * (1.0 + (0.5 * re)))) * sin(im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[(1/6 * re), $MachinePrecision] - -1/2), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[re, -540], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160], N[(N[(1 + N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(re * N[(N[(1/2 * re), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], N[(N[(1 + N[(re * N[(1 + N[(1/2 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(\frac{1}{6} \cdot re - \frac{-1}{2}\right) \cdot re\right) \cdot re\\
\mathbf{if}\;re \leq -540:\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{elif}\;re \leq 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160:\\
\;\;\;\;\left(1 + \frac{t\_0 \cdot t\_0 - re \cdot re}{re \cdot \left(\frac{1}{2} \cdot re - 1\right)}\right) \cdot \sin im\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right) \cdot \sin im\\
\end{array}
if re < -540Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
if -540 < re < 1.35e154Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6467.8%
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites55.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f6458.9%
Applied rewrites58.9%
if 1.35e154 < re Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs im) (fabs im)))
(t_1 (* (* (fabs im) -1/6) t_0))
(t_2 (sin (fabs im)))
(t_3 (* (exp re) t_2)))
(*
(copysign 1 im)
(if (<=
t_3
-999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448)
(*
(- (fabs im) (* (* t_0 1/6) (fabs im)))
(- (* (- (* 1/2 re) -1) re) -1))
(if (<= t_3 -3602879701896397/36028797018963968)
t_2
(if (<= t_3 0)
(/ (- (* t_1 t_1) t_0) (- t_1 (fabs im)))
(if (<= t_3 1)
t_2
(+
(fabs im)
(*
re
(+
(fabs im)
(*
re
(+
(* 1/6 (* (fabs im) re))
(* 1/2 (fabs im))))))))))))))double code(double re, double im) {
double t_0 = fabs(im) * fabs(im);
double t_1 = (fabs(im) * -0.16666666666666666) * t_0;
double t_2 = sin(fabs(im));
double t_3 = exp(re) * t_2;
double tmp;
if (t_3 <= -1e+168) {
tmp = (fabs(im) - ((t_0 * 0.16666666666666666) * fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = ((t_1 * t_1) - t_0) / (t_1 - fabs(im));
} else if (t_3 <= 1.0) {
tmp = t_2;
} else {
tmp = fabs(im) + (re * (fabs(im) + (re * ((0.16666666666666666 * (fabs(im) * re)) + (0.5 * fabs(im))))));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.abs(im) * Math.abs(im);
double t_1 = (Math.abs(im) * -0.16666666666666666) * t_0;
double t_2 = Math.sin(Math.abs(im));
double t_3 = Math.exp(re) * t_2;
double tmp;
if (t_3 <= -1e+168) {
tmp = (Math.abs(im) - ((t_0 * 0.16666666666666666) * Math.abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = ((t_1 * t_1) - t_0) / (t_1 - Math.abs(im));
} else if (t_3 <= 1.0) {
tmp = t_2;
} else {
tmp = Math.abs(im) + (re * (Math.abs(im) + (re * ((0.16666666666666666 * (Math.abs(im) * re)) + (0.5 * Math.abs(im))))));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.fabs(im) * math.fabs(im) t_1 = (math.fabs(im) * -0.16666666666666666) * t_0 t_2 = math.sin(math.fabs(im)) t_3 = math.exp(re) * t_2 tmp = 0 if t_3 <= -1e+168: tmp = (math.fabs(im) - ((t_0 * 0.16666666666666666) * math.fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0) elif t_3 <= -0.1: tmp = t_2 elif t_3 <= 0.0: tmp = ((t_1 * t_1) - t_0) / (t_1 - math.fabs(im)) elif t_3 <= 1.0: tmp = t_2 else: tmp = math.fabs(im) + (re * (math.fabs(im) + (re * ((0.16666666666666666 * (math.fabs(im) * re)) + (0.5 * math.fabs(im)))))) return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(abs(im) * abs(im)) t_1 = Float64(Float64(abs(im) * -0.16666666666666666) * t_0) t_2 = sin(abs(im)) t_3 = Float64(exp(re) * t_2) tmp = 0.0 if (t_3 <= -1e+168) tmp = Float64(Float64(abs(im) - Float64(Float64(t_0 * 0.16666666666666666) * abs(im))) * Float64(Float64(Float64(Float64(0.5 * re) - -1.0) * re) - -1.0)); elseif (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.0) tmp = Float64(Float64(Float64(t_1 * t_1) - t_0) / Float64(t_1 - abs(im))); elseif (t_3 <= 1.0) tmp = t_2; else tmp = Float64(abs(im) + Float64(re * Float64(abs(im) + Float64(re * Float64(Float64(0.16666666666666666 * Float64(abs(im) * re)) + Float64(0.5 * abs(im))))))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = abs(im) * abs(im); t_1 = (abs(im) * -0.16666666666666666) * t_0; t_2 = sin(abs(im)); t_3 = exp(re) * t_2; tmp = 0.0; if (t_3 <= -1e+168) tmp = (abs(im) - ((t_0 * 0.16666666666666666) * abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0); elseif (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.0) tmp = ((t_1 * t_1) - t_0) / (t_1 - abs(im)); elseif (t_3 <= 1.0) tmp = t_2; else tmp = abs(im) + (re * (abs(im) + (re * ((0.16666666666666666 * (abs(im) * re)) + (0.5 * abs(im)))))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[im], $MachinePrecision] * -1/6), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Exp[re], $MachinePrecision] * t$95$2), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448], N[(N[(N[Abs[im], $MachinePrecision] - N[(N[(t$95$0 * 1/6), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(1/2 * re), $MachinePrecision] - -1), $MachinePrecision] * re), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 0], N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$1 - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1], t$95$2, N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[(1/6 * N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot \left|im\right|\\
t_1 := \left(\left|im\right| \cdot \frac{-1}{6}\right) \cdot t\_0\\
t_2 := \sin \left(\left|im\right|\right)\\
t_3 := e^{re} \cdot t\_2\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -999999999999999933860494834742974562371950216430331518611692822307700646699603647625692432595845947170914554599698521475539380813444812793279458505403728617494385000448:\\
\;\;\;\;\left(\left|im\right| - \left(t\_0 \cdot \frac{1}{6}\right) \cdot \left|im\right|\right) \cdot \left(\left(\frac{1}{2} \cdot re - -1\right) \cdot re - -1\right)\\
\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;\frac{t\_1 \cdot t\_1 - t\_0}{t\_1 - \left|im\right|}\\
\mathbf{elif}\;t\_3 \leq 1:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + re \cdot \left(\left|im\right| + re \cdot \left(\frac{1}{6} \cdot \left(\left|im\right| \cdot re\right) + \frac{1}{2} \cdot \left|im\right|\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -9.9999999999999993e167Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.9%
Applied rewrites38.0%
if -9.9999999999999993e167 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.10000000000000001 or 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
if -0.10000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6430.4%
Applied rewrites30.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites21.2%
if 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6438.0%
Applied rewrites38.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs im) (fabs im)))
(t_1 (* (* (fabs im) -1/6) t_0))
(t_2 (* (exp re) (sin (fabs im)))))
(*
(copysign 1 im)
(if (<= t_2 -3602879701896397/36028797018963968)
(*
(- (fabs im) (* (* t_0 1/6) (fabs im)))
(- (* (- (* 1/2 re) -1) re) -1))
(if (<= t_2 0)
(/ (- (* t_1 t_1) t_0) (- t_1 (fabs im)))
(+
(fabs im)
(*
re
(+
(fabs im)
(* re (+ (* 1/6 (* (fabs im) re)) (* 1/2 (fabs im))))))))))))double code(double re, double im) {
double t_0 = fabs(im) * fabs(im);
double t_1 = (fabs(im) * -0.16666666666666666) * t_0;
double t_2 = exp(re) * sin(fabs(im));
double tmp;
if (t_2 <= -0.1) {
tmp = (fabs(im) - ((t_0 * 0.16666666666666666) * fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= 0.0) {
tmp = ((t_1 * t_1) - t_0) / (t_1 - fabs(im));
} else {
tmp = fabs(im) + (re * (fabs(im) + (re * ((0.16666666666666666 * (fabs(im) * re)) + (0.5 * fabs(im))))));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.abs(im) * Math.abs(im);
double t_1 = (Math.abs(im) * -0.16666666666666666) * t_0;
double t_2 = Math.exp(re) * Math.sin(Math.abs(im));
double tmp;
if (t_2 <= -0.1) {
tmp = (Math.abs(im) - ((t_0 * 0.16666666666666666) * Math.abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else if (t_2 <= 0.0) {
tmp = ((t_1 * t_1) - t_0) / (t_1 - Math.abs(im));
} else {
tmp = Math.abs(im) + (re * (Math.abs(im) + (re * ((0.16666666666666666 * (Math.abs(im) * re)) + (0.5 * Math.abs(im))))));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.fabs(im) * math.fabs(im) t_1 = (math.fabs(im) * -0.16666666666666666) * t_0 t_2 = math.exp(re) * math.sin(math.fabs(im)) tmp = 0 if t_2 <= -0.1: tmp = (math.fabs(im) - ((t_0 * 0.16666666666666666) * math.fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0) elif t_2 <= 0.0: tmp = ((t_1 * t_1) - t_0) / (t_1 - math.fabs(im)) else: tmp = math.fabs(im) + (re * (math.fabs(im) + (re * ((0.16666666666666666 * (math.fabs(im) * re)) + (0.5 * math.fabs(im)))))) return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(abs(im) * abs(im)) t_1 = Float64(Float64(abs(im) * -0.16666666666666666) * t_0) t_2 = Float64(exp(re) * sin(abs(im))) tmp = 0.0 if (t_2 <= -0.1) tmp = Float64(Float64(abs(im) - Float64(Float64(t_0 * 0.16666666666666666) * abs(im))) * Float64(Float64(Float64(Float64(0.5 * re) - -1.0) * re) - -1.0)); elseif (t_2 <= 0.0) tmp = Float64(Float64(Float64(t_1 * t_1) - t_0) / Float64(t_1 - abs(im))); else tmp = Float64(abs(im) + Float64(re * Float64(abs(im) + Float64(re * Float64(Float64(0.16666666666666666 * Float64(abs(im) * re)) + Float64(0.5 * abs(im))))))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = abs(im) * abs(im); t_1 = (abs(im) * -0.16666666666666666) * t_0; t_2 = exp(re) * sin(abs(im)); tmp = 0.0; if (t_2 <= -0.1) tmp = (abs(im) - ((t_0 * 0.16666666666666666) * abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0); elseif (t_2 <= 0.0) tmp = ((t_1 * t_1) - t_0) / (t_1 - abs(im)); else tmp = abs(im) + (re * (abs(im) + (re * ((0.16666666666666666 * (abs(im) * re)) + (0.5 * abs(im)))))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[im], $MachinePrecision] * -1/6), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[re], $MachinePrecision] * N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -3602879701896397/36028797018963968], N[(N[(N[Abs[im], $MachinePrecision] - N[(N[(t$95$0 * 1/6), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(1/2 * re), $MachinePrecision] - -1), $MachinePrecision] * re), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0], N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$1 - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[(1/6 * N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|im\right| \cdot \left|im\right|\\
t_1 := \left(\left|im\right| \cdot \frac{-1}{6}\right) \cdot t\_0\\
t_2 := e^{re} \cdot \sin \left(\left|im\right|\right)\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\left(\left|im\right| - \left(t\_0 \cdot \frac{1}{6}\right) \cdot \left|im\right|\right) \cdot \left(\left(\frac{1}{2} \cdot re - -1\right) \cdot re - -1\right)\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{t\_1 \cdot t\_1 - t\_0}{t\_1 - \left|im\right|}\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + re \cdot \left(\left|im\right| + re \cdot \left(\frac{1}{6} \cdot \left(\left|im\right| \cdot re\right) + \frac{1}{2} \cdot \left|im\right|\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.10000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.9%
Applied rewrites38.0%
if -0.10000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6430.4%
Applied rewrites30.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites21.2%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6438.0%
Applied rewrites38.0%
(FPCore (re im)
:precision binary64
(*
(copysign 1 im)
(if (<=
(sin (fabs im))
1488565707357403/372141426839350727961253789638658321589064376671906846864122981980487315514059736743009817965446945567110411062408283101969716033850703872)
(*
(- (fabs im) (* (* (* (fabs im) (fabs im)) 1/6) (fabs im)))
(- (* (- (* 1/2 re) -1) re) -1))
(+
(fabs im)
(*
re
(+
(fabs im)
(* re (+ (* 1/6 (* (fabs im) re)) (* 1/2 (fabs im))))))))))double code(double re, double im) {
double tmp;
if (sin(fabs(im)) <= 4e-123) {
tmp = (fabs(im) - (((fabs(im) * fabs(im)) * 0.16666666666666666) * fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else {
tmp = fabs(im) + (re * (fabs(im) + (re * ((0.16666666666666666 * (fabs(im) * re)) + (0.5 * fabs(im))))));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.sin(Math.abs(im)) <= 4e-123) {
tmp = (Math.abs(im) - (((Math.abs(im) * Math.abs(im)) * 0.16666666666666666) * Math.abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0);
} else {
tmp = Math.abs(im) + (re * (Math.abs(im) + (re * ((0.16666666666666666 * (Math.abs(im) * re)) + (0.5 * Math.abs(im))))));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if math.sin(math.fabs(im)) <= 4e-123: tmp = (math.fabs(im) - (((math.fabs(im) * math.fabs(im)) * 0.16666666666666666) * math.fabs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0) else: tmp = math.fabs(im) + (re * (math.fabs(im) + (re * ((0.16666666666666666 * (math.fabs(im) * re)) + (0.5 * math.fabs(im)))))) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (sin(abs(im)) <= 4e-123) tmp = Float64(Float64(abs(im) - Float64(Float64(Float64(abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * Float64(Float64(Float64(Float64(0.5 * re) - -1.0) * re) - -1.0)); else tmp = Float64(abs(im) + Float64(re * Float64(abs(im) + Float64(re * Float64(Float64(0.16666666666666666 * Float64(abs(im) * re)) + Float64(0.5 * abs(im))))))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if (sin(abs(im)) <= 4e-123) tmp = (abs(im) - (((abs(im) * abs(im)) * 0.16666666666666666) * abs(im))) * ((((0.5 * re) - -1.0) * re) - -1.0); else tmp = abs(im) + (re * (abs(im) + (re * ((0.16666666666666666 * (abs(im) * re)) + (0.5 * abs(im)))))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision], 1488565707357403/372141426839350727961253789638658321589064376671906846864122981980487315514059736743009817965446945567110411062408283101969716033850703872], N[(N[(N[Abs[im], $MachinePrecision] - N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * 1/6), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(1/2 * re), $MachinePrecision] - -1), $MachinePrecision] * re), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[(1/6 * N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|im\right|\right) \leq \frac{1488565707357403}{372141426839350727961253789638658321589064376671906846864122981980487315514059736743009817965446945567110411062408283101969716033850703872}:\\
\;\;\;\;\left(\left|im\right| - \left(\left(\left|im\right| \cdot \left|im\right|\right) \cdot \frac{1}{6}\right) \cdot \left|im\right|\right) \cdot \left(\left(\frac{1}{2} \cdot re - -1\right) \cdot re - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + re \cdot \left(\left|im\right| + re \cdot \left(\frac{1}{6} \cdot \left(\left|im\right| \cdot re\right) + \frac{1}{2} \cdot \left|im\right|\right)\right)\\
\end{array}
if (sin.f64 im) < 4.0000000000000002e-123Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6463.8%
Applied rewrites63.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.9%
Applied rewrites38.0%
if 4.0000000000000002e-123 < (sin.f64 im) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6438.0%
Applied rewrites38.0%
(FPCore (re im)
:precision binary64
(*
(copysign 1 im)
(if (<=
(* (exp re) (sin (fabs im)))
5764607523034235/144115188075855872)
(* (fabs im) (- (* (* -1/6 (fabs im)) (fabs im)) -1))
(+
(fabs im)
(*
re
(+
(fabs im)
(* re (+ (* 1/6 (* (fabs im) re)) (* 1/2 (fabs im))))))))))double code(double re, double im) {
double tmp;
if ((exp(re) * sin(fabs(im))) <= 0.04) {
tmp = fabs(im) * (((-0.16666666666666666 * fabs(im)) * fabs(im)) - -1.0);
} else {
tmp = fabs(im) + (re * (fabs(im) + (re * ((0.16666666666666666 * (fabs(im) * re)) + (0.5 * fabs(im))))));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(Math.abs(im))) <= 0.04) {
tmp = Math.abs(im) * (((-0.16666666666666666 * Math.abs(im)) * Math.abs(im)) - -1.0);
} else {
tmp = Math.abs(im) + (re * (Math.abs(im) + (re * ((0.16666666666666666 * (Math.abs(im) * re)) + (0.5 * Math.abs(im))))));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(math.fabs(im))) <= 0.04: tmp = math.fabs(im) * (((-0.16666666666666666 * math.fabs(im)) * math.fabs(im)) - -1.0) else: tmp = math.fabs(im) + (re * (math.fabs(im) + (re * ((0.16666666666666666 * (math.fabs(im) * re)) + (0.5 * math.fabs(im)))))) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(abs(im))) <= 0.04) tmp = Float64(abs(im) * Float64(Float64(Float64(-0.16666666666666666 * abs(im)) * abs(im)) - -1.0)); else tmp = Float64(abs(im) + Float64(re * Float64(abs(im) + Float64(re * Float64(Float64(0.16666666666666666 * Float64(abs(im) * re)) + Float64(0.5 * abs(im))))))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(abs(im))) <= 0.04) tmp = abs(im) * (((-0.16666666666666666 * abs(im)) * abs(im)) - -1.0); else tmp = abs(im) + (re * (abs(im) + (re * ((0.16666666666666666 * (abs(im) * re)) + (0.5 * abs(im)))))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5764607523034235/144115188075855872], N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[Abs[im], $MachinePrecision] + N[(re * N[(N[(1/6 * N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin \left(\left|im\right|\right) \leq \frac{5764607523034235}{144115188075855872}:\\
\;\;\;\;\left|im\right| \cdot \left(\left(\frac{-1}{6} \cdot \left|im\right|\right) \cdot \left|im\right| - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + re \cdot \left(\left|im\right| + re \cdot \left(\frac{1}{6} \cdot \left(\left|im\right| \cdot re\right) + \frac{1}{2} \cdot \left|im\right|\right)\right)\\
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.040000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6430.4%
Applied rewrites30.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6430.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6430.4%
Applied rewrites30.4%
if 0.040000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6438.0%
Applied rewrites38.0%
(FPCore (re im)
:precision binary64
(*
(copysign 1 im)
(if (<=
(* (exp re) (sin (fabs im)))
5764607523034235/144115188075855872)
(* (fabs im) (- (* (* -1/6 (fabs im)) (fabs im)) -1))
(+ (fabs im) (* (fabs im) (* re (+ 1 (* 1/2 re))))))))double code(double re, double im) {
double tmp;
if ((exp(re) * sin(fabs(im))) <= 0.04) {
tmp = fabs(im) * (((-0.16666666666666666 * fabs(im)) * fabs(im)) - -1.0);
} else {
tmp = fabs(im) + (fabs(im) * (re * (1.0 + (0.5 * re))));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(Math.abs(im))) <= 0.04) {
tmp = Math.abs(im) * (((-0.16666666666666666 * Math.abs(im)) * Math.abs(im)) - -1.0);
} else {
tmp = Math.abs(im) + (Math.abs(im) * (re * (1.0 + (0.5 * re))));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(math.fabs(im))) <= 0.04: tmp = math.fabs(im) * (((-0.16666666666666666 * math.fabs(im)) * math.fabs(im)) - -1.0) else: tmp = math.fabs(im) + (math.fabs(im) * (re * (1.0 + (0.5 * re)))) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(abs(im))) <= 0.04) tmp = Float64(abs(im) * Float64(Float64(Float64(-0.16666666666666666 * abs(im)) * abs(im)) - -1.0)); else tmp = Float64(abs(im) + Float64(abs(im) * Float64(re * Float64(1.0 + Float64(0.5 * re))))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(abs(im))) <= 0.04) tmp = abs(im) * (((-0.16666666666666666 * abs(im)) * abs(im)) - -1.0); else tmp = abs(im) + (abs(im) * (re * (1.0 + (0.5 * re)))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5764607523034235/144115188075855872], N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] + N[(N[Abs[im], $MachinePrecision] * N[(re * N[(1 + N[(1/2 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin \left(\left|im\right|\right) \leq \frac{5764607523034235}{144115188075855872}:\\
\;\;\;\;\left|im\right| \cdot \left(\left(\frac{-1}{6} \cdot \left|im\right|\right) \cdot \left|im\right| - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + \left|im\right| \cdot \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\\
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.040000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6430.4%
Applied rewrites30.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6430.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6430.4%
Applied rewrites30.4%
if 0.040000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6434.7%
Applied rewrites34.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6437.4%
Applied rewrites37.4%
(FPCore (re im)
:precision binary64
(*
(copysign 1 im)
(if (<=
(* (exp re) (sin (fabs im)))
5764607523034235/144115188075855872)
(* (fabs im) (- (* (* -1/6 (fabs im)) (fabs im)) -1))
(+ (fabs im) (* (fabs im) re)))))double code(double re, double im) {
double tmp;
if ((exp(re) * sin(fabs(im))) <= 0.04) {
tmp = fabs(im) * (((-0.16666666666666666 * fabs(im)) * fabs(im)) - -1.0);
} else {
tmp = fabs(im) + (fabs(im) * re);
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(Math.abs(im))) <= 0.04) {
tmp = Math.abs(im) * (((-0.16666666666666666 * Math.abs(im)) * Math.abs(im)) - -1.0);
} else {
tmp = Math.abs(im) + (Math.abs(im) * re);
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(math.fabs(im))) <= 0.04: tmp = math.fabs(im) * (((-0.16666666666666666 * math.fabs(im)) * math.fabs(im)) - -1.0) else: tmp = math.fabs(im) + (math.fabs(im) * re) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(abs(im))) <= 0.04) tmp = Float64(abs(im) * Float64(Float64(Float64(-0.16666666666666666 * abs(im)) * abs(im)) - -1.0)); else tmp = Float64(abs(im) + Float64(abs(im) * re)); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(abs(im))) <= 0.04) tmp = abs(im) * (((-0.16666666666666666 * abs(im)) * abs(im)) - -1.0); else tmp = abs(im) + (abs(im) * re); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5764607523034235/144115188075855872], N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(-1/6 * N[Abs[im], $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(N[Abs[im], $MachinePrecision] + N[(N[Abs[im], $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin \left(\left|im\right|\right) \leq \frac{5764607523034235}{144115188075855872}:\\
\;\;\;\;\left|im\right| \cdot \left(\left(\frac{-1}{6} \cdot \left|im\right|\right) \cdot \left|im\right| - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left|im\right| + \left|im\right| \cdot re\\
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.040000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-sin.f6451.2%
Applied rewrites51.2%
Taylor expanded in im around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6430.4%
Applied rewrites30.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6430.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6430.4%
Applied rewrites30.4%
if 0.040000000000000001 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
(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]
im + im \cdot re
Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f6430.0%
Applied rewrites30.0%
(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
im
Initial program 100.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-exp.f6468.7%
Applied rewrites68.7%
Taylor expanded in re around 0
Applied rewrites26.7%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))