
(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)))));
}
real(8) function code(k, m, n, m_1, l)
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 9 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)))));
}
real(8) function code(k, m, n, m_1, l)
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 (- n m)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - M), 2.0) + l)));
}
real(8) function code(k, m, n, m_1, l)
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((n - m)) - (((((m + n) / 2.0d0) - 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((n - m)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 77.3%
associate-/l*77.7%
+-commutative77.7%
associate-/l*77.3%
associate-/l*77.7%
+-commutative77.7%
exp-diff21.8%
sub-neg21.8%
exp-sum17.9%
associate-/r*17.9%
exp-diff25.0%
Simplified77.7%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Final simplification95.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -3000000000.0) (not (<= M 41.0))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (- (fabs (- n m)) l) (* 0.25 (* (+ m n) (+ m n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -3000000000.0) || !(M <= 41.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp(((fabs((n - m)) - l) - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
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 <= (-3000000000.0d0)) .or. (.not. (m_1 <= 41.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp(((abs((n - m)) - l) - (0.25d0 * ((m + n) * (m + 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 <= -3000000000.0) || !(M <= 41.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((Math.abs((n - m)) - l) - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -3000000000.0) or not (M <= 41.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((math.fabs((n - m)) - l) - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -3000000000.0) || !(M <= 41.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(abs(Float64(n - m)) - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -3000000000.0) || ~((M <= 41.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp(((abs((n - m)) - l) - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -3000000000.0], N[Not[LessEqual[M, 41.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -3000000000 \lor \neg \left(M \leq 41\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\end{array}
\end{array}
if M < -3e9 or 41 < M Initial program 81.4%
associate-/l*82.2%
+-commutative82.2%
associate-/l*81.4%
associate-/l*82.2%
+-commutative82.2%
exp-diff24.8%
sub-neg24.8%
exp-sum20.9%
associate-/r*20.9%
exp-diff29.5%
Simplified82.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 95.4%
mul-1-neg95.4%
Simplified95.4%
if -3e9 < M < 41Initial program 73.2%
associate-/l*73.2%
+-commutative73.2%
associate-/l*73.2%
associate-/l*73.2%
+-commutative73.2%
exp-diff18.8%
sub-neg18.8%
exp-sum14.9%
associate-/r*14.9%
exp-diff20.4%
Simplified73.2%
Taylor expanded in K around 0 80.1%
cos-neg80.1%
associate-*r*80.1%
sin-neg80.1%
Simplified80.1%
Taylor expanded in M around 0 91.3%
associate--r+91.3%
+-commutative91.3%
Simplified91.3%
unpow291.3%
Applied egg-rr91.3%
Final simplification93.4%
(FPCore (K m n M l)
:precision binary64
(if (<= m -0.33)
(exp (* (pow m 2.0) -0.25))
(if (or (<= m -9e-127) (not (<= m -8.2e-207)))
(exp (* -0.25 (pow n 2.0)))
(exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.33) {
tmp = exp((pow(m, 2.0) * -0.25));
} else if ((m <= -9e-127) || !(m <= -8.2e-207)) {
tmp = exp((-0.25 * pow(n, 2.0)));
} else {
tmp = exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
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 <= (-0.33d0)) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else if ((m <= (-9d-127)) .or. (.not. (m <= (-8.2d-207)))) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
else
tmp = 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 (m <= -0.33) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else if ((m <= -9e-127) || !(m <= -8.2e-207)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.33: tmp = math.exp((math.pow(m, 2.0) * -0.25)) elif (m <= -9e-127) or not (m <= -8.2e-207): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.33) tmp = exp(Float64((m ^ 2.0) * -0.25)); elseif ((m <= -9e-127) || !(m <= -8.2e-207)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -0.33) tmp = exp(((m ^ 2.0) * -0.25)); elseif ((m <= -9e-127) || ~((m <= -8.2e-207))) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.33], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[m, -9e-127], N[Not[LessEqual[m, -8.2e-207]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.33:\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -9 \cdot 10^{-127} \lor \neg \left(m \leq -8.2 \cdot 10^{-207}\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -0.330000000000000016Initial program 73.0%
associate-/l*73.0%
+-commutative73.0%
associate-/l*73.0%
associate-/l*73.0%
+-commutative73.0%
exp-diff3.2%
sub-neg3.2%
exp-sum0.0%
associate-/r*0.0%
exp-diff1.6%
Simplified73.0%
Taylor expanded in K around 0 77.8%
cos-neg77.8%
associate-*r*77.8%
sin-neg77.8%
Simplified77.8%
Taylor expanded in M around 0 100.0%
associate--r+100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 95.3%
*-commutative95.3%
Simplified95.3%
if -0.330000000000000016 < m < -8.9999999999999998e-127 or -8.1999999999999998e-207 < m Initial program 79.4%
associate-/l*79.9%
+-commutative79.9%
associate-/l*79.4%
associate-/l*79.9%
+-commutative79.9%
exp-diff27.7%
sub-neg27.7%
exp-sum23.7%
associate-/r*23.7%
exp-diff32.2%
Simplified79.9%
Taylor expanded in K around 0 81.5%
cos-neg81.5%
associate-*r*81.5%
sin-neg81.5%
Simplified81.5%
Taylor expanded in M around 0 80.3%
associate--r+80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in n around inf 49.3%
*-commutative49.3%
Simplified49.3%
if -8.9999999999999998e-127 < m < -8.1999999999999998e-207Initial program 72.2%
associate-/l*72.2%
+-commutative72.2%
associate-/l*72.2%
associate-/l*72.2%
+-commutative72.2%
exp-diff31.0%
sub-neg31.0%
exp-sum25.1%
associate-/r*25.1%
exp-diff36.9%
Simplified72.2%
Taylor expanded in K around 0 78.0%
cos-neg78.0%
associate-*r*78.0%
sin-neg78.0%
Simplified78.0%
Taylor expanded in M around 0 84.0%
associate--r+84.0%
+-commutative84.0%
Simplified84.0%
Taylor expanded in l around inf 55.4%
neg-mul-155.4%
Simplified55.4%
Final simplification61.1%
(FPCore (K m n M l)
:precision binary64
(if (<= m -0.33)
(exp (* (pow m 2.0) -0.25))
(if (or (<= m -1.05e-125) (not (<= m -1.68e-205)))
(exp (* -0.25 (pow n 2.0)))
(* (cos M) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.33) {
tmp = exp((pow(m, 2.0) * -0.25));
} else if ((m <= -1.05e-125) || !(m <= -1.68e-205)) {
tmp = exp((-0.25 * pow(n, 2.0)));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
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 <= (-0.33d0)) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else if ((m <= (-1.05d-125)) .or. (.not. (m <= (-1.68d-205)))) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
else
tmp = cos(m_1) * 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 (m <= -0.33) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else if ((m <= -1.05e-125) || !(m <= -1.68e-205)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.33: tmp = math.exp((math.pow(m, 2.0) * -0.25)) elif (m <= -1.05e-125) or not (m <= -1.68e-205): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.33) tmp = exp(Float64((m ^ 2.0) * -0.25)); elseif ((m <= -1.05e-125) || !(m <= -1.68e-205)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -0.33) tmp = exp(((m ^ 2.0) * -0.25)); elseif ((m <= -1.05e-125) || ~((m <= -1.68e-205))) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.33], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[m, -1.05e-125], N[Not[LessEqual[m, -1.68e-205]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.33:\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -1.05 \cdot 10^{-125} \lor \neg \left(m \leq -1.68 \cdot 10^{-205}\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -0.330000000000000016Initial program 73.0%
associate-/l*73.0%
+-commutative73.0%
associate-/l*73.0%
associate-/l*73.0%
+-commutative73.0%
exp-diff3.2%
sub-neg3.2%
exp-sum0.0%
associate-/r*0.0%
exp-diff1.6%
Simplified73.0%
Taylor expanded in K around 0 77.8%
cos-neg77.8%
associate-*r*77.8%
sin-neg77.8%
Simplified77.8%
Taylor expanded in M around 0 100.0%
associate--r+100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 95.3%
*-commutative95.3%
Simplified95.3%
if -0.330000000000000016 < m < -1.05e-125 or -1.68000000000000008e-205 < m Initial program 79.4%
associate-/l*79.9%
+-commutative79.9%
associate-/l*79.4%
associate-/l*79.9%
+-commutative79.9%
exp-diff27.7%
sub-neg27.7%
exp-sum23.7%
associate-/r*23.7%
exp-diff32.2%
Simplified79.9%
Taylor expanded in K around 0 81.5%
cos-neg81.5%
associate-*r*81.5%
sin-neg81.5%
Simplified81.5%
Taylor expanded in M around 0 80.3%
associate--r+80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in n around inf 49.3%
*-commutative49.3%
Simplified49.3%
if -1.05e-125 < m < -1.68000000000000008e-205Initial program 72.2%
associate-/l*72.2%
+-commutative72.2%
associate-/l*72.2%
associate-/l*72.2%
+-commutative72.2%
exp-diff31.0%
sub-neg31.0%
exp-sum25.1%
associate-/r*25.1%
exp-diff36.9%
Simplified72.2%
Taylor expanded in K around 0 89.7%
cos-neg89.7%
Simplified89.7%
Taylor expanded in l around inf 55.4%
mul-1-neg49.3%
Simplified55.4%
Final simplification61.1%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- n m)) l) (* 0.25 (* (+ m n) (+ m n))))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((n - m)) - l) - (0.25 * ((m + n) * (m + n)))));
}
real(8) function code(k, m, n, m_1, l)
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(((abs((n - m)) - l) - (0.25d0 * ((m + n) * (m + n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((n - m)) - l) - (0.25 * ((m + n) * (m + n)))));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((n - m)) - l) - (0.25 * ((m + n) * (m + n)))))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(n - m)) - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((n - m)) - l) - (0.25 * ((m + n) * (m + n))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}
\end{array}
Initial program 77.3%
associate-/l*77.7%
+-commutative77.7%
associate-/l*77.3%
associate-/l*77.7%
+-commutative77.7%
exp-diff21.8%
sub-neg21.8%
exp-sum17.9%
associate-/r*17.9%
exp-diff25.0%
Simplified77.7%
Taylor expanded in K around 0 80.4%
cos-neg80.4%
associate-*r*80.4%
sin-neg80.4%
Simplified80.4%
Taylor expanded in M around 0 85.4%
associate--r+85.4%
+-commutative85.4%
Simplified85.4%
unpow285.4%
Applied egg-rr85.4%
Final simplification85.4%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -54.0) (not (<= m 5.8e-20))) (exp (* (pow m 2.0) -0.25)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -54.0) || !(m <= 5.8e-20)) {
tmp = exp((pow(m, 2.0) * -0.25));
} else {
tmp = exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
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 <= (-54.0d0)) .or. (.not. (m <= 5.8d-20))) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = 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 ((m <= -54.0) || !(m <= 5.8e-20)) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -54.0) or not (m <= 5.8e-20): tmp = math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -54.0) || !(m <= 5.8e-20)) tmp = exp(Float64((m ^ 2.0) * -0.25)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -54.0) || ~((m <= 5.8e-20))) tmp = exp(((m ^ 2.0) * -0.25)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -54.0], N[Not[LessEqual[m, 5.8e-20]], $MachinePrecision]], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54 \lor \neg \left(m \leq 5.8 \cdot 10^{-20}\right):\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -54 or 5.8e-20 < m Initial program 70.9%
associate-/l*70.9%
+-commutative70.9%
associate-/l*70.9%
associate-/l*70.9%
+-commutative70.9%
exp-diff4.7%
sub-neg4.7%
exp-sum1.6%
associate-/r*1.6%
exp-diff3.1%
Simplified70.9%
Taylor expanded in K around 0 78.0%
cos-neg78.0%
associate-*r*78.0%
sin-neg78.0%
Simplified78.0%
Taylor expanded in M around 0 99.2%
associate--r+99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in m around inf 96.0%
*-commutative96.0%
Simplified96.0%
if -54 < m < 5.8e-20Initial program 83.7%
associate-/l*84.4%
+-commutative84.4%
associate-/l*83.7%
associate-/l*84.4%
+-commutative84.4%
exp-diff38.7%
sub-neg38.7%
exp-sum34.1%
associate-/r*34.1%
exp-diff46.5%
Simplified84.4%
Taylor expanded in K around 0 82.8%
cos-neg82.8%
associate-*r*82.8%
sin-neg82.8%
Simplified82.8%
Taylor expanded in M around 0 71.7%
associate--r+71.7%
+-commutative71.7%
Simplified71.7%
Taylor expanded in l around inf 35.4%
neg-mul-135.4%
Simplified35.4%
Final simplification65.5%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
real(8) function code(k, m, n, m_1, l)
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(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 77.3%
associate-/l*77.7%
+-commutative77.7%
associate-/l*77.3%
associate-/l*77.7%
+-commutative77.7%
exp-diff21.8%
sub-neg21.8%
exp-sum17.9%
associate-/r*17.9%
exp-diff25.0%
Simplified77.7%
Taylor expanded in K around 0 80.4%
cos-neg80.4%
associate-*r*80.4%
sin-neg80.4%
Simplified80.4%
Taylor expanded in M around 0 85.4%
associate--r+85.4%
+-commutative85.4%
Simplified85.4%
Taylor expanded in l around inf 30.5%
neg-mul-130.5%
Simplified30.5%
Final simplification30.5%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
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)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 77.3%
associate-/l*77.7%
+-commutative77.7%
associate-/l*77.3%
associate-/l*77.7%
+-commutative77.7%
exp-diff21.8%
sub-neg21.8%
exp-sum17.9%
associate-/r*17.9%
exp-diff25.0%
Simplified77.7%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in l around inf 32.1%
mul-1-neg29.0%
Simplified32.1%
Taylor expanded in l around 0 6.6%
Final simplification6.6%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
real(8) function code(k, m, n, m_1, l)
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
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 77.3%
associate-/l*77.7%
+-commutative77.7%
associate-/l*77.3%
associate-/l*77.7%
+-commutative77.7%
exp-diff21.8%
sub-neg21.8%
exp-sum17.9%
associate-/r*17.9%
exp-diff25.0%
Simplified77.7%
Taylor expanded in K around 0 80.4%
cos-neg80.4%
associate-*r*80.4%
sin-neg80.4%
Simplified80.4%
Taylor expanded in l around inf 29.0%
mul-1-neg29.0%
Simplified29.0%
Taylor expanded in l around 0 6.0%
cos-neg6.0%
+-commutative6.0%
associate-*r*6.0%
*-commutative6.0%
cos-neg6.0%
Simplified6.0%
Taylor expanded in M around 0 6.6%
Final simplification6.6%
herbie shell --seed 2024077
(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)))))))