
(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}
Sampling outcomes in binary64 precision:
Herbie found 10 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 (* (cos M) (exp (- (fabs (- m n)) (+ (pow (- (* 0.5 (+ n m)) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((m - n)) - (pow(((0.5 * (n + m)) - M), 2.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 = cos(m_1) * exp((abs((m - n)) - ((((0.5d0 * (n + m)) - m_1) ** 2.0d0) + l)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp((Math.abs((m - n)) - (Math.pow(((0.5 * (n + m)) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((m - n)) - (math.pow(((0.5 * (n + m)) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - Float64((Float64(Float64(0.5 * Float64(n + m)) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((m - n)) - ((((0.5 * (n + m)) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|m - n\right| - \left({\left(0.5 \cdot \left(n + m\right) - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 73.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
lower-+.f64N/A
Applied rewrites95.3%
Final simplification95.3%
(FPCore (K m n M l)
:precision binary64
(if (or (<= M -2e+154) (not (<= M 2e+112)))
(* (cos M) (exp (* (- M) M)))
(*
(+ 1.0 (* -0.5 (* M M)))
(exp (- (fabs (- m n)) (+ (pow (- (* 0.5 (+ n m)) M) 2.0) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -2e+154) || !(M <= 2e+112)) {
tmp = cos(M) * exp((-M * M));
} else {
tmp = (1.0 + (-0.5 * (M * M))) * exp((fabs((m - n)) - (pow(((0.5 * (n + m)) - M), 2.0) + l)));
}
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_1 <= (-2d+154)) .or. (.not. (m_1 <= 2d+112))) then
tmp = cos(m_1) * exp((-m_1 * m_1))
else
tmp = (1.0d0 + ((-0.5d0) * (m_1 * m_1))) * exp((abs((m - n)) - ((((0.5d0 * (n + m)) - m_1) ** 2.0d0) + l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -2e+154) || !(M <= 2e+112)) {
tmp = Math.cos(M) * Math.exp((-M * M));
} else {
tmp = (1.0 + (-0.5 * (M * M))) * Math.exp((Math.abs((m - n)) - (Math.pow(((0.5 * (n + m)) - M), 2.0) + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -2e+154) or not (M <= 2e+112): tmp = math.cos(M) * math.exp((-M * M)) else: tmp = (1.0 + (-0.5 * (M * M))) * math.exp((math.fabs((m - n)) - (math.pow(((0.5 * (n + m)) - M), 2.0) + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -2e+154) || !(M <= 2e+112)) tmp = Float64(cos(M) * exp(Float64(Float64(-M) * M))); else tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(M * M))) * exp(Float64(abs(Float64(m - n)) - Float64((Float64(Float64(0.5 * Float64(n + m)) - M) ^ 2.0) + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -2e+154) || ~((M <= 2e+112))) tmp = cos(M) * exp((-M * M)); else tmp = (1.0 + (-0.5 * (M * M))) * exp((abs((m - n)) - ((((0.5 * (n + m)) - M) ^ 2.0) + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -2e+154], N[Not[LessEqual[M, 2e+112]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-0.5 * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -2 \cdot 10^{+154} \lor \neg \left(M \leq 2 \cdot 10^{+112}\right):\\
\;\;\;\;\cos M \cdot e^{\left(-M\right) \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + -0.5 \cdot \left(M \cdot M\right)\right) \cdot e^{\left|m - n\right| - \left({\left(0.5 \cdot \left(n + m\right) - M\right)}^{2} + \ell\right)}\\
\end{array}
\end{array}
if M < -2.00000000000000007e154 or 1.9999999999999999e112 < M Initial program 74.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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in M around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -2.00000000000000007e154 < M < 1.9999999999999999e112Initial program 72.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
lower-+.f64N/A
Applied rewrites92.9%
Taylor expanded in M around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6492.0
Applied rewrites92.0%
Final simplification94.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* (- M) M))))
(if (<= n -2.8e-269)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 5.3e-168)
(* (sin (* 0.5 (* K n))) t_0)
(if (<= n 55.0)
(* (sin (- (* 0.5 PI) M)) t_0)
(* (cos M) (exp (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-M * M));
double tmp;
if (n <= -2.8e-269) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 5.3e-168) {
tmp = sin((0.5 * (K * n))) * t_0;
} else if (n <= 55.0) {
tmp = sin(((0.5 * ((double) M_PI)) - M)) * t_0;
} else {
tmp = cos(M) * exp((-0.25 * (n * n)));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-M * M));
double tmp;
if (n <= -2.8e-269) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 5.3e-168) {
tmp = Math.sin((0.5 * (K * n))) * t_0;
} else if (n <= 55.0) {
tmp = Math.sin(((0.5 * Math.PI) - M)) * t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-M * M)) tmp = 0 if n <= -2.8e-269: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 5.3e-168: tmp = math.sin((0.5 * (K * n))) * t_0 elif n <= 55.0: tmp = math.sin(((0.5 * math.pi) - M)) * t_0 else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(Float64(-M) * M)) tmp = 0.0 if (n <= -2.8e-269) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 5.3e-168) tmp = Float64(sin(Float64(0.5 * Float64(K * n))) * t_0); elseif (n <= 55.0) tmp = Float64(sin(Float64(Float64(0.5 * pi) - M)) * t_0); else tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-M * M)); tmp = 0.0; if (n <= -2.8e-269) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 5.3e-168) tmp = sin((0.5 * (K * n))) * t_0; elseif (n <= 55.0) tmp = sin(((0.5 * pi) - M)) * t_0; else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -2.8e-269], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5.3e-168], N[(N[Sin[N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Sin[N[(N[(0.5 * Pi), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-M\right) \cdot M}\\
\mathbf{if}\;n \leq -2.8 \cdot 10^{-269}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 5.3 \cdot 10^{-168}:\\
\;\;\;\;\sin \left(0.5 \cdot \left(K \cdot n\right)\right) \cdot t\_0\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\sin \left(0.5 \cdot \pi - M\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -2.79999999999999995e-269Initial program 70.9%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6432.9
Applied rewrites32.9%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6452.6
Applied rewrites52.6%
if -2.79999999999999995e-269 < n < 5.29999999999999977e-168Initial program 73.8%
lift-cos.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites71.8%
Taylor expanded in n around inf
lower-*.f64N/A
lower-*.f6484.2
Applied rewrites84.2%
Taylor expanded in M around inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6465.3
Applied rewrites65.3%
if 5.29999999999999977e-168 < n < 55Initial program 80.4%
lift-cos.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites80.4%
Taylor expanded in n around inf
lower-*.f64N/A
lower-*.f6473.5
Applied rewrites73.5%
Taylor expanded in M around inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6455.5
Applied rewrites55.5%
Taylor expanded in K around 0
lower--.f64N/A
lower-*.f64N/A
lift-PI.f6465.5
Applied rewrites65.5%
if 55 < n Initial program 73.1%
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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification65.2%
(FPCore (K m n M l)
:precision binary64
(if (<= n -2.55e-179)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 55.0)
(* (sin (* 0.5 (* K n))) (exp (- (+ (* M M) l))))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -2.55e-179) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = sin((0.5 * (K * n))) * exp(-((M * M) + l));
} else {
tmp = cos(M) * 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.55d-179)) then
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
else if (n <= 55.0d0) then
tmp = sin((0.5d0 * (k * n))) * exp(-((m_1 * m_1) + l))
else
tmp = cos(m_1) * 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.55e-179) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = Math.sin((0.5 * (K * n))) * Math.exp(-((M * M) + l));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -2.55e-179: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 55.0: tmp = math.sin((0.5 * (K * n))) * math.exp(-((M * M) + l)) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -2.55e-179) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 55.0) tmp = Float64(sin(Float64(0.5 * Float64(K * n))) * exp(Float64(-Float64(Float64(M * M) + l)))); else tmp = Float64(cos(M) * 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.55e-179) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 55.0) tmp = sin((0.5 * (K * n))) * exp(-((M * M) + l)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -2.55e-179], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Sin[N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[(-N[(N[(M * M), $MachinePrecision] + l), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.55 \cdot 10^{-179}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\sin \left(0.5 \cdot \left(K \cdot n\right)\right) \cdot e^{-\left(M \cdot M + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -2.55000000000000014e-179Initial program 70.2%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.3
Applied rewrites31.3%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6451.4
Applied rewrites51.4%
if -2.55000000000000014e-179 < n < 55Initial program 77.2%
lift-cos.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites76.6%
Taylor expanded in n around inf
lower-*.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
Taylor expanded in M around inf
unpow2N/A
lower-*.f6459.0
Applied rewrites59.0%
Taylor expanded in l around inf
Applied rewrites74.1%
if 55 < n Initial program 73.1%
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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification68.2%
(FPCore (K m n M l)
:precision binary64
(if (<= n 1.12e-208)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 55.0)
(* (sin (- (* 0.5 PI) M)) (exp (* (- M) M)))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.12e-208) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = sin(((0.5 * ((double) M_PI)) - M)) * exp((-M * M));
} else {
tmp = cos(M) * exp((-0.25 * (n * n)));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.12e-208) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = Math.sin(((0.5 * Math.PI) - M)) * Math.exp((-M * M));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.12e-208: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 55.0: tmp = math.sin(((0.5 * math.pi) - M)) * math.exp((-M * M)) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.12e-208) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 55.0) tmp = Float64(sin(Float64(Float64(0.5 * pi) - M)) * exp(Float64(Float64(-M) * M))); else tmp = Float64(cos(M) * 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 <= 1.12e-208) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 55.0) tmp = sin(((0.5 * pi) - M)) * exp((-M * M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.12e-208], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Sin[N[(N[(0.5 * Pi), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.12 \cdot 10^{-208}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\sin \left(0.5 \cdot \pi - M\right) \cdot e^{\left(-M\right) \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.12000000000000005e-208Initial program 71.4%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6435.3
Applied rewrites35.3%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6453.9
Applied rewrites53.9%
if 1.12000000000000005e-208 < n < 55Initial program 79.4%
lift-cos.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites79.7%
Taylor expanded in n around inf
lower-*.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in M around inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6458.6
Applied rewrites58.6%
Taylor expanded in K around 0
lower--.f64N/A
lower-*.f64N/A
lift-PI.f6464.4
Applied rewrites64.4%
if 55 < n Initial program 73.1%
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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification64.4%
(FPCore (K m n M l)
:precision binary64
(if (<= n 1.12e-208)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 55.0)
(* (cos M) (exp (* (- M) M)))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.12e-208) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = cos(M) * exp((-M * M));
} else {
tmp = cos(M) * 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 <= 1.12d-208) then
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
else if (n <= 55.0d0) then
tmp = cos(m_1) * exp((-m_1 * m_1))
else
tmp = cos(m_1) * 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 <= 1.12e-208) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 55.0) {
tmp = Math.cos(M) * Math.exp((-M * M));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.12e-208: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 55.0: tmp = math.cos(M) * math.exp((-M * M)) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.12e-208) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 55.0) tmp = Float64(cos(M) * exp(Float64(Float64(-M) * M))); else tmp = Float64(cos(M) * 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 <= 1.12e-208) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 55.0) tmp = cos(M) * exp((-M * M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.12e-208], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.12 \cdot 10^{-208}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\cos M \cdot e^{\left(-M\right) \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.12000000000000005e-208Initial program 71.4%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6435.3
Applied rewrites35.3%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6453.9
Applied rewrites53.9%
if 1.12000000000000005e-208 < n < 55Initial program 79.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
lower-+.f64N/A
Applied rewrites91.4%
Taylor expanded in M around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6464.4
Applied rewrites64.4%
if 55 < n Initial program 73.1%
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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification64.4%
(FPCore (K m n M l) :precision binary64 (if (<= n 55.0) (* (cos M) (exp (* (- M) M))) (* (cos M) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 55.0) {
tmp = cos(M) * exp((-M * M));
} else {
tmp = cos(M) * 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 <= 55.0d0) then
tmp = cos(m_1) * exp((-m_1 * m_1))
else
tmp = cos(m_1) * 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 <= 55.0) {
tmp = Math.cos(M) * Math.exp((-M * M));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 55.0: tmp = math.cos(M) * math.exp((-M * M)) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 55.0) tmp = Float64(cos(M) * exp(Float64(Float64(-M) * M))); else tmp = Float64(cos(M) * 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 <= 55.0) tmp = cos(M) * exp((-M * M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 55.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 55:\\
\;\;\;\;\cos M \cdot e^{\left(-M\right) \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 55Initial program 73.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
lower-+.f64N/A
Applied rewrites94.1%
Taylor expanded in M around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6459.6
Applied rewrites59.6%
if 55 < n Initial program 73.1%
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
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification67.0%
(FPCore (K m n M l) :precision binary64 (if (<= l 0.85) (* (cos M) (exp (* (- M) M))) (* 1.0 (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.85) {
tmp = cos(M) * exp((-M * M));
} else {
tmp = 1.0 * exp(-l);
}
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 (l <= 0.85d0) then
tmp = cos(m_1) * exp((-m_1 * m_1))
else
tmp = 1.0d0 * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.85) {
tmp = Math.cos(M) * Math.exp((-M * M));
} else {
tmp = 1.0 * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 0.85: tmp = math.cos(M) * math.exp((-M * M)) else: tmp = 1.0 * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 0.85) tmp = Float64(cos(M) * exp(Float64(Float64(-M) * M))); else tmp = Float64(1.0 * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 0.85) tmp = cos(M) * exp((-M * M)); else tmp = 1.0 * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 0.85], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.85:\\
\;\;\;\;\cos M \cdot e^{\left(-M\right) \cdot M}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 0.849999999999999978Initial program 73.6%
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
lower-+.f64N/A
Applied rewrites93.8%
Taylor expanded in M around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
if 0.849999999999999978 < l Initial program 71.9%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6471.9
Applied rewrites71.9%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in M around 0
Applied rewrites100.0%
Final simplification70.7%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(-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 = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 73.2%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6425.4
Applied rewrites25.4%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6432.7
Applied rewrites32.7%
(FPCore (K m n M l) :precision binary64 (* 1.0 (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return 1.0 * exp(-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 = 1.0d0 * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0 * Math.exp(-l);
}
def code(K, m, n, M, l): return 1.0 * math.exp(-l)
function code(K, m, n, M, l) return Float64(1.0 * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = 1.0 * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(1.0 * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot e^{-\ell}
\end{array}
Initial program 73.2%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6425.4
Applied rewrites25.4%
Taylor expanded in K around 0
cos-neg-revN/A
lift-cos.f6432.7
Applied rewrites32.7%
Taylor expanded in M around 0
Applied rewrites32.3%
herbie shell --seed 2025071
(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)))))))