
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (- (* 0.5 (+ n m)) M))) (* 1.0 (exp (- (fabs (- n m)) (fma t_0 t_0 l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (n + m)) - M;
return 1.0 * exp((fabs((n - m)) - fma(t_0, t_0, l)));
}
function code(K, m, n, M, l) t_0 = Float64(Float64(0.5 * Float64(n + m)) - M) return Float64(1.0 * exp(Float64(abs(Float64(n - m)) - fma(t_0, t_0, l)))) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[(1.0 * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 * t$95$0 + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(n + m\right) - M\\
1 \cdot e^{\left|n - m\right| - \mathsf{fma}\left(t\_0, t\_0, \ell\right)}
\end{array}
\end{array}
Initial program 75.3%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.7%
Taylor expanded in M around 0
Applied rewrites96.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* 1.0 (exp (* -1.0 (* M M))))))
(if (<= M -1.9e+19)
t_0
(if (<= M 5.6e+20)
(exp (- (fabs (- n m)) (- l (* (* (+ m n) (+ m n)) -0.25))))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = 1.0 * exp((-1.0 * (M * M)));
double tmp;
if (M <= -1.9e+19) {
tmp = t_0;
} else if (M <= 5.6e+20) {
tmp = exp((fabs((n - m)) - (l - (((m + n) * (m + n)) * -0.25))));
} else {
tmp = t_0;
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 * exp(((-1.0d0) * (m_1 * m_1)))
if (m_1 <= (-1.9d+19)) then
tmp = t_0
else if (m_1 <= 5.6d+20) then
tmp = exp((abs((n - m)) - (l - (((m + n) * (m + n)) * (-0.25d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = 1.0 * Math.exp((-1.0 * (M * M)));
double tmp;
if (M <= -1.9e+19) {
tmp = t_0;
} else if (M <= 5.6e+20) {
tmp = Math.exp((Math.abs((n - m)) - (l - (((m + n) * (m + n)) * -0.25))));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = 1.0 * math.exp((-1.0 * (M * M))) tmp = 0 if M <= -1.9e+19: tmp = t_0 elif M <= 5.6e+20: tmp = math.exp((math.fabs((n - m)) - (l - (((m + n) * (m + n)) * -0.25)))) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = Float64(1.0 * exp(Float64(-1.0 * Float64(M * M)))) tmp = 0.0 if (M <= -1.9e+19) tmp = t_0; elseif (M <= 5.6e+20) tmp = exp(Float64(abs(Float64(n - m)) - Float64(l - Float64(Float64(Float64(m + n) * Float64(m + n)) * -0.25)))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = 1.0 * exp((-1.0 * (M * M))); tmp = 0.0; if (M <= -1.9e+19) tmp = t_0; elseif (M <= 5.6e+20) tmp = exp((abs((n - m)) - (l - (((m + n) * (m + n)) * -0.25)))); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(1.0 * N[Exp[N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -1.9e+19], t$95$0, If[LessEqual[M, 5.6e+20], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l - N[(N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot e^{-1 \cdot \left(M \cdot M\right)}\\
\mathbf{if}\;M \leq -1.9 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 5.6 \cdot 10^{+20}:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell - \left(\left(m + n\right) \cdot \left(m + n\right)\right) \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -1.9e19 or 5.6e20 < M Initial program 77.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in M around 0
Applied rewrites98.9%
Taylor expanded in M around inf
lower-*.f64N/A
pow2N/A
lift-*.f6497.6
Applied rewrites97.6%
if -1.9e19 < M < 5.6e20Initial program 73.3%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.1%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6493.2
Applied rewrites93.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -1.0 (* M M)))) (t_1 (* 1.0 t_0)))
(if (<= M -31000000000000.0)
t_1
(if (<= M -1.5e-156)
(exp (* -0.25 (* m m)))
(if (<= M 1.02e-166)
(* (* -0.5 (* M M)) t_0)
(if (<= M 27.0) (exp (* -0.25 (* n n))) t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-1.0 * (M * M)));
double t_1 = 1.0 * t_0;
double tmp;
if (M <= -31000000000000.0) {
tmp = t_1;
} else if (M <= -1.5e-156) {
tmp = exp((-0.25 * (m * m)));
} else if (M <= 1.02e-166) {
tmp = (-0.5 * (M * M)) * t_0;
} else if (M <= 27.0) {
tmp = exp((-0.25 * (n * n)));
} else {
tmp = t_1;
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(((-1.0d0) * (m_1 * m_1)))
t_1 = 1.0d0 * t_0
if (m_1 <= (-31000000000000.0d0)) then
tmp = t_1
else if (m_1 <= (-1.5d-156)) then
tmp = exp(((-0.25d0) * (m * m)))
else if (m_1 <= 1.02d-166) then
tmp = ((-0.5d0) * (m_1 * m_1)) * t_0
else if (m_1 <= 27.0d0) then
tmp = exp(((-0.25d0) * (n * n)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-1.0 * (M * M)));
double t_1 = 1.0 * t_0;
double tmp;
if (M <= -31000000000000.0) {
tmp = t_1;
} else if (M <= -1.5e-156) {
tmp = Math.exp((-0.25 * (m * m)));
} else if (M <= 1.02e-166) {
tmp = (-0.5 * (M * M)) * t_0;
} else if (M <= 27.0) {
tmp = Math.exp((-0.25 * (n * n)));
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-1.0 * (M * M))) t_1 = 1.0 * t_0 tmp = 0 if M <= -31000000000000.0: tmp = t_1 elif M <= -1.5e-156: tmp = math.exp((-0.25 * (m * m))) elif M <= 1.02e-166: tmp = (-0.5 * (M * M)) * t_0 elif M <= 27.0: tmp = math.exp((-0.25 * (n * n))) else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-1.0 * Float64(M * M))) t_1 = Float64(1.0 * t_0) tmp = 0.0 if (M <= -31000000000000.0) tmp = t_1; elseif (M <= -1.5e-156) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (M <= 1.02e-166) tmp = Float64(Float64(-0.5 * Float64(M * M)) * t_0); elseif (M <= 27.0) tmp = exp(Float64(-0.25 * Float64(n * n))); else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-1.0 * (M * M))); t_1 = 1.0 * t_0; tmp = 0.0; if (M <= -31000000000000.0) tmp = t_1; elseif (M <= -1.5e-156) tmp = exp((-0.25 * (m * m))); elseif (M <= 1.02e-166) tmp = (-0.5 * (M * M)) * t_0; elseif (M <= 27.0) tmp = exp((-0.25 * (n * n))); else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 * t$95$0), $MachinePrecision]}, If[LessEqual[M, -31000000000000.0], t$95$1, If[LessEqual[M, -1.5e-156], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[M, 1.02e-166], N[(N[(-0.5 * N[(M * M), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[M, 27.0], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-1 \cdot \left(M \cdot M\right)}\\
t_1 := 1 \cdot t\_0\\
\mathbf{if}\;M \leq -31000000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq -1.5 \cdot 10^{-156}:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;M \leq 1.02 \cdot 10^{-166}:\\
\;\;\;\;\left(-0.5 \cdot \left(M \cdot M\right)\right) \cdot t\_0\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if M < -3.1e13 or 27 < M Initial program 77.8%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in M around 0
Applied rewrites98.7%
Taylor expanded in M around inf
lower-*.f64N/A
pow2N/A
lift-*.f6497.2
Applied rewrites97.2%
if -3.1e13 < M < -1.5e-156Initial program 74.9%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites95.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6494.2
Applied rewrites94.2%
Taylor expanded in m around inf
lower-*.f64N/A
pow2N/A
lift-*.f6455.4
Applied rewrites55.4%
if -1.5e-156 < M < 1.02000000000000007e-166Initial program 72.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites93.9%
Taylor expanded in M around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lift-*.f6493.9
Applied rewrites93.9%
Taylor expanded in M around inf
lower-*.f64N/A
pow2N/A
lift-*.f6410.7
Applied rewrites10.7%
Taylor expanded in M around inf
lower-*.f64N/A
pow2N/A
lift-*.f6476.4
Applied rewrites76.4%
if 1.02000000000000007e-166 < M < 27Initial program 71.4%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites92.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6492.4
Applied rewrites92.4%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6457.2
Applied rewrites57.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(exp (* -0.25 (* m m)))
(if (<= m 2.6e-131)
(* 1.0 (exp (* -1.0 (* M M))))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * (m * m)));
} else if (m <= 2.6e-131) {
tmp = 1.0 * exp((-1.0 * (M * M)));
} else {
tmp = exp((-0.25 * (n * n)));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-55.0d0)) then
tmp = exp(((-0.25d0) * (m * m)))
else if (m <= 2.6d-131) then
tmp = 1.0d0 * exp(((-1.0d0) * (m_1 * m_1)))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = Math.exp((-0.25 * (m * m)));
} else if (m <= 2.6e-131) {
tmp = 1.0 * Math.exp((-1.0 * (M * M)));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -55.0: tmp = math.exp((-0.25 * (m * m))) elif m <= 2.6e-131: tmp = 1.0 * math.exp((-1.0 * (M * M))) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (m <= 2.6e-131) tmp = Float64(1.0 * exp(Float64(-1.0 * Float64(M * M)))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -55.0) tmp = exp((-0.25 * (m * m))); elseif (m <= 2.6e-131) tmp = 1.0 * exp((-1.0 * (M * M))); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2.6e-131], N[(1.0 * N[Exp[N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq 2.6 \cdot 10^{-131}:\\
\;\;\;\;1 \cdot e^{-1 \cdot \left(M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -55Initial program 68.9%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites99.0%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6497.2
Applied rewrites97.2%
Taylor expanded in m around inf
lower-*.f64N/A
pow2N/A
lift-*.f6496.9
Applied rewrites96.9%
if -55 < m < 2.59999999999999996e-131Initial program 81.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.7%
Taylor expanded in M around 0
Applied rewrites93.8%
Taylor expanded in M around inf
lower-*.f64N/A
pow2N/A
lift-*.f6455.2
Applied rewrites55.2%
if 2.59999999999999996e-131 < m Initial program 72.8%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites97.2%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6490.7
Applied rewrites90.7%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6452.7
Applied rewrites52.7%
(FPCore (K m n M l) :precision binary64 (if (<= n 2.35e-170) (exp (* -0.25 (* m m))) (if (<= n 0.0155) (exp (- (fabs (- n m)) l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2.35e-170) {
tmp = exp((-0.25 * (m * m)));
} else if (n <= 0.0155) {
tmp = exp((fabs((n - m)) - l));
} else {
tmp = exp((-0.25 * (n * n)));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (n <= 2.35d-170) then
tmp = exp(((-0.25d0) * (m * m)))
else if (n <= 0.0155d0) then
tmp = exp((abs((n - m)) - l))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2.35e-170) {
tmp = Math.exp((-0.25 * (m * m)));
} else if (n <= 0.0155) {
tmp = Math.exp((Math.abs((n - m)) - l));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 2.35e-170: tmp = math.exp((-0.25 * (m * m))) elif n <= 0.0155: tmp = math.exp((math.fabs((n - m)) - l)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 2.35e-170) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (n <= 0.0155) tmp = exp(Float64(abs(Float64(n - m)) - l)); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 2.35e-170) tmp = exp((-0.25 * (m * m))); elseif (n <= 0.0155) tmp = exp((abs((n - m)) - l)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2.35e-170], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 0.0155], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 2.35 \cdot 10^{-170}:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 0.0155:\\
\;\;\;\;e^{\left|n - m\right| - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2.3500000000000001e-170Initial program 76.2%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6485.5
Applied rewrites85.5%
Taylor expanded in m around inf
lower-*.f64N/A
pow2N/A
lift-*.f6453.5
Applied rewrites53.5%
if 2.3500000000000001e-170 < n < 0.0155Initial program 80.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites93.0%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6474.9
Applied rewrites74.9%
Taylor expanded in l around inf
Applied rewrites34.2%
if 0.0155 < n Initial program 70.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites99.0%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6497.1
Applied rewrites97.1%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
(FPCore (K m n M l) :precision binary64 (if (<= n 2.35e-170) (exp (* -0.25 (* m m))) (if (<= n 1.06e-19) (exp (* -1.0 l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2.35e-170) {
tmp = exp((-0.25 * (m * m)));
} else if (n <= 1.06e-19) {
tmp = exp((-1.0 * l));
} else {
tmp = exp((-0.25 * (n * n)));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (n <= 2.35d-170) then
tmp = exp(((-0.25d0) * (m * m)))
else if (n <= 1.06d-19) then
tmp = exp(((-1.0d0) * l))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2.35e-170) {
tmp = Math.exp((-0.25 * (m * m)));
} else if (n <= 1.06e-19) {
tmp = Math.exp((-1.0 * l));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 2.35e-170: tmp = math.exp((-0.25 * (m * m))) elif n <= 1.06e-19: tmp = math.exp((-1.0 * l)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 2.35e-170) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (n <= 1.06e-19) tmp = exp(Float64(-1.0 * l)); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 2.35e-170) tmp = exp((-0.25 * (m * m))); elseif (n <= 1.06e-19) tmp = exp((-1.0 * l)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2.35e-170], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 1.06e-19], N[Exp[N[(-1.0 * l), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 2.35 \cdot 10^{-170}:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 1.06 \cdot 10^{-19}:\\
\;\;\;\;e^{-1 \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2.3500000000000001e-170Initial program 76.2%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6485.5
Applied rewrites85.5%
Taylor expanded in m around inf
lower-*.f64N/A
pow2N/A
lift-*.f6453.5
Applied rewrites53.5%
if 2.3500000000000001e-170 < n < 1.06e-19Initial program 80.5%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites93.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6475.5
Applied rewrites75.5%
Taylor expanded in l around inf
lower-*.f6441.5
Applied rewrites41.5%
if 1.06e-19 < n Initial program 70.9%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites98.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6495.8
Applied rewrites95.8%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6492.0
Applied rewrites92.0%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* -0.25 (* m m))))) (if (<= m -0.0002) t_0 (if (<= m 5.8e-87) (exp (* -1.0 l)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * (m * m)));
double tmp;
if (m <= -0.0002) {
tmp = t_0;
} else if (m <= 5.8e-87) {
tmp = exp((-1.0 * l));
} else {
tmp = t_0;
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp(((-0.25d0) * (m * m)))
if (m <= (-0.0002d0)) then
tmp = t_0
else if (m <= 5.8d-87) then
tmp = exp(((-1.0d0) * l))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-0.25 * (m * m)));
double tmp;
if (m <= -0.0002) {
tmp = t_0;
} else if (m <= 5.8e-87) {
tmp = Math.exp((-1.0 * l));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * (m * m))) tmp = 0 if m <= -0.0002: tmp = t_0 elif m <= 5.8e-87: tmp = math.exp((-1.0 * l)) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * Float64(m * m))) tmp = 0.0 if (m <= -0.0002) tmp = t_0; elseif (m <= 5.8e-87) tmp = exp(Float64(-1.0 * l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (m * m))); tmp = 0.0; if (m <= -0.0002) tmp = t_0; elseif (m <= 5.8e-87) tmp = exp((-1.0 * l)); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -0.0002], t$95$0, If[LessEqual[m, 5.8e-87], N[Exp[N[(-1.0 * l), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;m \leq -0.0002:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5.8 \cdot 10^{-87}:\\
\;\;\;\;e^{-1 \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -2.0000000000000001e-4 or 5.7999999999999998e-87 < m Initial program 70.7%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites98.3%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6494.5
Applied rewrites94.5%
Taylor expanded in m around inf
lower-*.f64N/A
pow2N/A
lift-*.f6484.4
Applied rewrites84.4%
if -2.0000000000000001e-4 < m < 5.7999999999999998e-87Initial program 81.3%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.5%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6477.2
Applied rewrites77.2%
Taylor expanded in l around inf
lower-*.f6442.7
Applied rewrites42.7%
(FPCore (K m n M l) :precision binary64 (exp (* -1.0 l)))
double code(double K, double m, double n, double M, double l) {
return exp((-1.0 * l));
}
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(k, m, n, m_1, l)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(((-1.0d0) * l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((-1.0 * l));
}
def code(K, m, n, M, l): return math.exp((-1.0 * l))
function code(K, m, n, M, l) return exp(Float64(-1.0 * l)) end
function tmp = code(K, m, n, M, l) tmp = exp((-1.0 * l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(-1.0 * l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{-1 \cdot \ell}
\end{array}
Initial program 75.3%
Taylor expanded in K around 0
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.7%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
lift--.f64N/A
lift-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6487.1
Applied rewrites87.1%
Taylor expanded in l around inf
lower-*.f6435.3
Applied rewrites35.3%
herbie shell --seed 2025121
(FPCore (K m n M l)
:name "Maksimov and Kolovsky, Equation (32)"
:precision binary64
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))