
(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 (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.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 = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - 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((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 74.9%
Taylor expanded in K around 0 96.9%
cos-neg96.9%
Simplified96.9%
Final simplification96.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -1260000.0) (not (<= m 53.0))) (* (cos M) (exp (* (pow m 2.0) -0.25))) (* (cos M) (exp (- (pow M 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1260000.0) || !(m <= 53.0)) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp(-pow(M, 2.0));
}
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 <= (-1260000.0d0)) .or. (.not. (m <= 53.0d0))) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1260000.0) || !(m <= 53.0)) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -1260000.0) or not (m <= 53.0): tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -1260000.0) || !(m <= 53.0)) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); else tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -1260000.0) || ~((m <= 53.0))) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); else tmp = cos(M) * exp(-(M ^ 2.0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -1260000.0], N[Not[LessEqual[m, 53.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1260000 \lor \neg \left(m \leq 53\right):\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\end{array}
\end{array}
if m < -1.26e6 or 53 < m Initial program 71.4%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 99.2%
*-commutative70.6%
Simplified99.2%
if -1.26e6 < m < 53Initial program 78.4%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in M around inf 63.2%
mul-1-neg63.2%
Simplified63.2%
Final simplification80.9%
(FPCore (K m n M l)
:precision binary64
(if (<= n 4.2e-177)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= n 54.0)
(* (cos M) (exp (- (pow M 2.0))))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 4.2e-177) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (n <= 54.0) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
}
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 (n <= 4.2d-177) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (n <= 54.0d0) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 4.2e-177) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (n <= 54.0) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 4.2e-177: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif n <= 54.0: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 4.2e-177) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 4.2e-177) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif (n <= 54.0) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 4.2e-177], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 4.2 \cdot 10^{-177}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 4.20000000000000002e-177Initial program 76.1%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in m around inf 55.4%
*-commutative43.9%
Simplified55.4%
if 4.20000000000000002e-177 < n < 54Initial program 85.3%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in M around inf 59.7%
mul-1-neg59.7%
Simplified59.7%
if 54 < n Initial program 69.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification69.1%
(FPCore (K m n M l) :precision binary64 (if (<= l 720.0) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 720.0) {
tmp = cos(M) * exp(-pow(M, 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 (l <= 720.0d0) then
tmp = cos(m_1) * exp(-(m_1 ** 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 (l <= 720.0) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 720.0: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 720.0) tmp = Float64(cos(M) * exp(Float64(-(M ^ 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 (l <= 720.0) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 720.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 720:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 720Initial program 74.4%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in M around inf 53.9%
mul-1-neg53.9%
Simplified53.9%
if 720 < l Initial program 76.7%
Taylor expanded in l around inf 76.7%
mul-1-neg76.7%
Simplified76.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification64.7%
(FPCore (K m n M l) :precision binary64 (if (<= l 7.6e-21) (* -0.5 (* K (* m (sin (- (* 0.5 (* n K)) M))))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 7.6e-21) {
tmp = -0.5 * (K * (m * sin(((0.5 * (n * K)) - M))));
} 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 (l <= 7.6d-21) then
tmp = (-0.5d0) * (k * (m * sin(((0.5d0 * (n * k)) - m_1))))
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 (l <= 7.6e-21) {
tmp = -0.5 * (K * (m * Math.sin(((0.5 * (n * K)) - M))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 7.6e-21: tmp = -0.5 * (K * (m * math.sin(((0.5 * (n * K)) - M)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 7.6e-21) tmp = Float64(-0.5 * Float64(K * Float64(m * sin(Float64(Float64(0.5 * Float64(n * K)) - M))))); 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 (l <= 7.6e-21) tmp = -0.5 * (K * (m * sin(((0.5 * (n * K)) - M)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 7.6e-21], N[(-0.5 * N[(K * N[(m * N[Sin[N[(N[(0.5 * N[(n * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.6 \cdot 10^{-21}:\\
\;\;\;\;-0.5 \cdot \left(K \cdot \left(m \cdot \sin \left(0.5 \cdot \left(n \cdot K\right) - M\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 7.5999999999999995e-21Initial program 75.3%
Taylor expanded in m around inf 40.0%
*-commutative40.0%
Simplified40.0%
Taylor expanded in m around 0 7.2%
*-commutative7.2%
associate-*r*7.2%
*-commutative7.2%
*-commutative7.2%
Simplified7.2%
Taylor expanded in K around inf 17.1%
if 7.5999999999999995e-21 < l Initial program 73.8%
Taylor expanded in l around inf 70.9%
mul-1-neg70.9%
Simplified70.9%
Taylor expanded in K around 0 92.5%
cos-neg92.5%
Simplified92.5%
Final simplification36.3%
(FPCore (K m n M l) :precision binary64 (if (<= m -2.9e-19) (* 0.5 (* K (* n (sin M)))) (* -0.5 (* K (* m (sin (- (* 0.5 (* n K)) M)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.9e-19) {
tmp = 0.5 * (K * (n * sin(M)));
} else {
tmp = -0.5 * (K * (m * sin(((0.5 * (n * K)) - M))));
}
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 <= (-2.9d-19)) then
tmp = 0.5d0 * (k * (n * sin(m_1)))
else
tmp = (-0.5d0) * (k * (m * sin(((0.5d0 * (n * k)) - m_1))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.9e-19) {
tmp = 0.5 * (K * (n * Math.sin(M)));
} else {
tmp = -0.5 * (K * (m * Math.sin(((0.5 * (n * K)) - M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2.9e-19: tmp = 0.5 * (K * (n * math.sin(M))) else: tmp = -0.5 * (K * (m * math.sin(((0.5 * (n * K)) - M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2.9e-19) tmp = Float64(0.5 * Float64(K * Float64(n * sin(M)))); else tmp = Float64(-0.5 * Float64(K * Float64(m * sin(Float64(Float64(0.5 * Float64(n * K)) - M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2.9e-19) tmp = 0.5 * (K * (n * sin(M))); else tmp = -0.5 * (K * (m * sin(((0.5 * (n * K)) - M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.9e-19], N[(0.5 * N[(K * N[(n * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(K * N[(m * N[Sin[N[(N[(0.5 * N[(n * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(n \cdot \sin M\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(K \cdot \left(m \cdot \sin \left(0.5 \cdot \left(n \cdot K\right) - M\right)\right)\right)\\
\end{array}
\end{array}
if m < -2.9e-19Initial program 71.6%
Taylor expanded in m around inf 62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in m around 0 2.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in n around 0 2.7%
cos-neg2.7%
*-commutative2.7%
sin-neg2.7%
Simplified2.7%
Taylor expanded in K around inf 18.7%
if -2.9e-19 < m Initial program 76.1%
Taylor expanded in m around inf 32.3%
*-commutative32.3%
Simplified32.3%
Taylor expanded in m around 0 7.3%
*-commutative7.3%
associate-*r*7.3%
*-commutative7.3%
*-commutative7.3%
Simplified7.3%
Taylor expanded in K around inf 20.6%
Final simplification20.1%
(FPCore (K m n M l) :precision binary64 (* 0.5 (* K (* n (sin M)))))
double code(double K, double m, double n, double M, double l) {
return 0.5 * (K * (n * sin(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 = 0.5d0 * (k * (n * sin(m_1)))
end function
public static double code(double K, double m, double n, double M, double l) {
return 0.5 * (K * (n * Math.sin(M)));
}
def code(K, m, n, M, l): return 0.5 * (K * (n * math.sin(M)))
function code(K, m, n, M, l) return Float64(0.5 * Float64(K * Float64(n * sin(M)))) end
function tmp = code(K, m, n, M, l) tmp = 0.5 * (K * (n * sin(M))); end
code[K_, m_, n_, M_, l_] := N[(0.5 * N[(K * N[(n * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(K \cdot \left(n \cdot \sin M\right)\right)
\end{array}
Initial program 74.9%
Taylor expanded in m around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in m around 0 6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in n around 0 6.0%
cos-neg6.0%
*-commutative6.0%
sin-neg6.0%
Simplified6.0%
Taylor expanded in K around inf 19.2%
Final simplification19.2%
(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(Float64(-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 \left(-M\right)
\end{array}
Initial program 74.9%
Taylor expanded in m around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in m around 0 6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in n around 0 6.6%
neg-mul-16.6%
Simplified6.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 74.9%
Taylor expanded in m around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in m around 0 6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in n around 0 6.0%
cos-neg6.0%
*-commutative6.0%
sin-neg6.0%
Simplified6.0%
Taylor expanded in M around 0 6.6%
Final simplification6.6%
herbie shell --seed 2023310
(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)))))))