
(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 7 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)) (+ l (pow (- (* 0.5 (+ m n)) M) 2.0))))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) * exp((fabs((m - n)) - (l + pow(((0.5 * (m + n)) - M), 2.0))));
}
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)) - (l + (((0.5d0 * (m + n)) - m_1) ** 2.0d0))))
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)) - (l + Math.pow(((0.5 * (m + n)) - M), 2.0))));
}
def code(K, m, n, M, l): return math.cos(-M) * math.exp((math.fabs((m - n)) - (l + math.pow(((0.5 * (m + n)) - M), 2.0))))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * exp(Float64(abs(Float64(m - n)) - Float64(l + (Float64(Float64(0.5 * Float64(m + n)) - M) ^ 2.0))))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) * exp((abs((m - n)) - (l + (((0.5 * (m + n)) - M) ^ 2.0)))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(0.5 \cdot \left(m + n\right) - M\right)}^{2}\right)}
\end{array}
Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (- (* 0.5 (+ n m)) M))) (* 1.0 (/ 1.0 (exp (- (fma t_0 t_0 l) (fabs (- n m))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (n + m)) - M;
return 1.0 * (1.0 / exp((fma(t_0, t_0, l) - fabs((n - m)))));
}
function code(K, m, n, M, l) t_0 = Float64(Float64(0.5 * Float64(n + m)) - M) return Float64(1.0 * Float64(1.0 / exp(Float64(fma(t_0, t_0, l) - abs(Float64(n - m)))))) 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[(1.0 / N[Exp[N[(N[(t$95$0 * t$95$0 + l), $MachinePrecision] - N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(n + m\right) - M\\
1 \cdot \frac{1}{e^{\mathsf{fma}\left(t\_0, t\_0, \ell\right) - \left|n - m\right|}}
\end{array}
\end{array}
Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
Applied rewrites96.5%
Applied rewrites96.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* 1.0 (exp (* -1.0 (pow M 2.0))))))
(if (<= M -5e+34)
t_0
(if (<= M 6e+60)
(exp (- (fabs (- n m)) (fma (* 0.25 (+ n m)) (+ n m) l)))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = 1.0 * exp((-1.0 * pow(M, 2.0)));
double tmp;
if (M <= -5e+34) {
tmp = t_0;
} else if (M <= 6e+60) {
tmp = exp((fabs((n - m)) - fma((0.25 * (n + m)), (n + m), l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(1.0 * exp(Float64(-1.0 * (M ^ 2.0)))) tmp = 0.0 if (M <= -5e+34) tmp = t_0; elseif (M <= 6e+60) tmp = exp(Float64(abs(Float64(n - m)) - fma(Float64(0.25 * Float64(n + m)), Float64(n + m), l))); else tmp = t_0; end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(1.0 * N[Exp[N[(-1.0 * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -5e+34], t$95$0, If[LessEqual[M, 6e+60], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[(0.25 * N[(n + m), $MachinePrecision]), $MachinePrecision] * N[(n + m), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot e^{-1 \cdot {M}^{2}}\\
\mathbf{if}\;M \leq -5 \cdot 10^{+34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 6 \cdot 10^{+60}:\\
\;\;\;\;e^{\left|n - m\right| - \mathsf{fma}\left(0.25 \cdot \left(n + m\right), n + m, \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -4.9999999999999998e34 or 5.9999999999999997e60 < M Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
Applied rewrites96.5%
Taylor expanded in M around inf
lower-*.f64N/A
lower-pow.f6454.1
Applied rewrites54.1%
if -4.9999999999999998e34 < M < 5.9999999999999997e60Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
(FPCore (K m n M l) :precision binary64 (if (<= n 6500000.0) (exp (- (fabs (- n m)) (fma (* 0.25 m) (+ n m) l))) (exp (* -0.25 (pow n 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 6500000.0) {
tmp = exp((fabs((n - m)) - fma((0.25 * m), (n + m), l)));
} else {
tmp = exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
function code(K, m, n, M, l) tmp = 0.0 if (n <= 6500000.0) tmp = exp(Float64(abs(Float64(n - m)) - fma(Float64(0.25 * m), Float64(n + m), l))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 6500000.0], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[(0.25 * m), $MachinePrecision] * N[(n + m), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 6500000:\\
\;\;\;\;e^{\left|n - m\right| - \mathsf{fma}\left(0.25 \cdot m, n + m, \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 6.5e6Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
Taylor expanded in m around inf
lower-*.f6460.8
Applied rewrites60.8%
if 6.5e6 < n Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
Taylor expanded in n around inf
lower-*.f64N/A
lower-pow.f6454.9
Applied rewrites54.9%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) (fma (* 0.25 (+ n m)) (+ n m) l))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - fma((0.25 * (n + m)), (n + m), l)));
}
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - fma(Float64(0.25 * Float64(n + m)), Float64(n + m), l))) end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[(0.25 * N[(n + m), $MachinePrecision]), $MachinePrecision] * N[(n + m), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \mathsf{fma}\left(0.25 \cdot \left(n + m\right), n + m, \ell\right)}
\end{array}
Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 9.5e+46)
(exp (- t_0 (fma (* 0.25 m) (+ n m) l)))
(exp (- t_0 (fma (* 0.25 n) n l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 9.5e+46) {
tmp = exp((t_0 - fma((0.25 * m), (n + m), l)));
} else {
tmp = exp((t_0 - fma((0.25 * n), n, l)));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 9.5e+46) tmp = exp(Float64(t_0 - fma(Float64(0.25 * m), Float64(n + m), l))); else tmp = exp(Float64(t_0 - fma(Float64(0.25 * n), n, l))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 9.5e+46], N[Exp[N[(t$95$0 - N[(N[(0.25 * m), $MachinePrecision] * N[(n + m), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - N[(N[(0.25 * n), $MachinePrecision] * n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 9.5 \cdot 10^{+46}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25 \cdot m, n + m, \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25 \cdot n, n, \ell\right)}\\
\end{array}
\end{array}
if n < 9.5000000000000008e46Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
Taylor expanded in m around inf
lower-*.f6460.8
Applied rewrites60.8%
if 9.5000000000000008e46 < n Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
Taylor expanded in m around 0
Applied rewrites60.4%
Taylor expanded in m around 0
Applied rewrites60.5%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) (fma (* 0.25 n) n l))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - fma((0.25 * n), n, l)));
}
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - fma(Float64(0.25 * n), n, l))) end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[(0.25 * n), $MachinePrecision] * n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \mathsf{fma}\left(0.25 \cdot n, n, \ell\right)}
\end{array}
Initial program 75.4%
Taylor expanded in K around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f6487.1
Applied rewrites87.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites87.1%
Taylor expanded in m around 0
Applied rewrites60.4%
Taylor expanded in m around 0
Applied rewrites60.5%
herbie shell --seed 2025162
(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)))))))