
(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 11 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)) l) (pow (- (/ (+ n m) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((n + m) / 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((n - m)) - l) - ((((n + m) / 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((n - m)) - l) - Math.pow((((n + m) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((n + m) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - ((((n + m) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(n + m), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}}
\end{array}
Initial program 75.9%
Simplified75.9%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0
(* (exp (- (- n m) (+ (* M M) l))) (cos (- (* (+ n m) (* 0.5 K)) M))))
(t_1 (* (cos M) (exp (* -0.25 (* m m))))))
(if (<= n 1.9e-208)
t_1
(if (<= n 2e-126)
t_0
(if (<= n 4.9e-89)
t_1
(if (<= n 185.0) t_0 (exp (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((n - m) - ((M * M) + l))) * cos((((n + m) * (0.5 * K)) - M));
double t_1 = cos(M) * exp((-0.25 * (m * m)));
double tmp;
if (n <= 1.9e-208) {
tmp = t_1;
} else if (n <= 2e-126) {
tmp = t_0;
} else if (n <= 4.9e-89) {
tmp = t_1;
} else if (n <= 185.0) {
tmp = t_0;
} else {
tmp = exp((-0.25 * (n * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(((n - m) - ((m_1 * m_1) + l))) * cos((((n + m) * (0.5d0 * k)) - m_1))
t_1 = cos(m_1) * exp(((-0.25d0) * (m * m)))
if (n <= 1.9d-208) then
tmp = t_1
else if (n <= 2d-126) then
tmp = t_0
else if (n <= 4.9d-89) then
tmp = t_1
else if (n <= 185.0d0) then
tmp = t_0
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(((n - m) - ((M * M) + l))) * Math.cos((((n + m) * (0.5 * K)) - M));
double t_1 = Math.cos(M) * Math.exp((-0.25 * (m * m)));
double tmp;
if (n <= 1.9e-208) {
tmp = t_1;
} else if (n <= 2e-126) {
tmp = t_0;
} else if (n <= 4.9e-89) {
tmp = t_1;
} else if (n <= 185.0) {
tmp = t_0;
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(((n - m) - ((M * M) + l))) * math.cos((((n + m) * (0.5 * K)) - M)) t_1 = math.cos(M) * math.exp((-0.25 * (m * m))) tmp = 0 if n <= 1.9e-208: tmp = t_1 elif n <= 2e-126: tmp = t_0 elif n <= 4.9e-89: tmp = t_1 elif n <= 185.0: tmp = t_0 else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = Float64(exp(Float64(Float64(n - m) - Float64(Float64(M * M) + l))) * cos(Float64(Float64(Float64(n + m) * Float64(0.5 * K)) - M))) t_1 = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))) tmp = 0.0 if (n <= 1.9e-208) tmp = t_1; elseif (n <= 2e-126) tmp = t_0; elseif (n <= 4.9e-89) tmp = t_1; elseif (n <= 185.0) tmp = t_0; else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(((n - m) - ((M * M) + l))) * cos((((n + m) * (0.5 * K)) - M)); t_1 = cos(M) * exp((-0.25 * (m * m))); tmp = 0.0; if (n <= 1.9e-208) tmp = t_1; elseif (n <= 2e-126) tmp = t_0; elseif (n <= 4.9e-89) tmp = t_1; elseif (n <= 185.0) tmp = t_0; else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[(N[(n - m), $MachinePrecision] - N[(N[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(N[(n + m), $MachinePrecision] * N[(0.5 * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, 1.9e-208], t$95$1, If[LessEqual[n, 2e-126], t$95$0, If[LessEqual[n, 4.9e-89], t$95$1, If[LessEqual[n, 185.0], t$95$0, N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(n - m\right) - \left(M \cdot M + \ell\right)} \cdot \cos \left(\left(n + m\right) \cdot \left(0.5 \cdot K\right) - M\right)\\
t_1 := \cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;n \leq 1.9 \cdot 10^{-208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 2 \cdot 10^{-126}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 4.9 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 185:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.90000000000000006e-208 or 1.9999999999999999e-126 < n < 4.9e-89Initial program 76.0%
Simplified76.0%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in m around inf 59.1%
unpow259.1%
Simplified59.1%
if 1.90000000000000006e-208 < n < 1.9999999999999999e-126 or 4.9e-89 < n < 185Initial program 91.2%
Simplified91.2%
*-commutative91.2%
Applied egg-rr90.0%
Taylor expanded in M around inf 81.3%
unpow281.3%
Simplified81.3%
if 185 < n Initial program 68.5%
Simplified68.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 98.7%
unpow298.7%
Simplified98.7%
Taylor expanded in M around 0 98.7%
Final simplification73.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* (+ n m) 0.5))))
(if (<= n 2e+27)
(* (exp (- (- n m) (+ l (* t_0 t_0)))) (cos (- (* 0.5 (* n K)) M)))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - ((n + m) * 0.5);
double tmp;
if (n <= 2e+27) {
tmp = exp(((n - m) - (l + (t_0 * t_0)))) * cos(((0.5 * (n * K)) - M));
} else {
tmp = exp((-0.25 * (n * 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) :: t_0
real(8) :: tmp
t_0 = m_1 - ((n + m) * 0.5d0)
if (n <= 2d+27) then
tmp = exp(((n - m) - (l + (t_0 * t_0)))) * cos(((0.5d0 * (n * k)) - m_1))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = M - ((n + m) * 0.5);
double tmp;
if (n <= 2e+27) {
tmp = Math.exp(((n - m) - (l + (t_0 * t_0)))) * Math.cos(((0.5 * (n * K)) - M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - ((n + m) * 0.5) tmp = 0 if n <= 2e+27: tmp = math.exp(((n - m) - (l + (t_0 * t_0)))) * math.cos(((0.5 * (n * K)) - M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(Float64(n + m) * 0.5)) tmp = 0.0 if (n <= 2e+27) tmp = Float64(exp(Float64(Float64(n - m) - Float64(l + Float64(t_0 * t_0)))) * cos(Float64(Float64(0.5 * Float64(n * K)) - M))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - ((n + m) * 0.5); tmp = 0.0; if (n <= 2e+27) tmp = exp(((n - m) - (l + (t_0 * t_0)))) * cos(((0.5 * (n * K)) - M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(N[(n + m), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, 2e+27], N[(N[Exp[N[(N[(n - m), $MachinePrecision] - N[(l + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(0.5 * N[(n * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - \left(n + m\right) \cdot 0.5\\
\mathbf{if}\;n \leq 2 \cdot 10^{+27}:\\
\;\;\;\;e^{\left(n - m\right) - \left(\ell + t\_0 \cdot t\_0\right)} \cdot \cos \left(0.5 \cdot \left(n \cdot K\right) - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2e27Initial program 78.4%
Simplified78.4%
*-commutative78.4%
Applied egg-rr78.2%
Taylor expanded in m around 0 88.7%
*-commutative88.7%
Simplified88.7%
if 2e27 < n Initial program 68.7%
Simplified68.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification91.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -0.25 (* n n)))) (t_1 (* (cos M) (exp (* M (- M))))))
(if (<= M -1.65e-9)
t_1
(if (<= M -8.5e-209)
t_0
(if (<= M 2.4e-222)
(* (exp (- l)) (* M (* M -0.5)))
(if (<= M 5000000000000.0) (* t_0 (+ 1.0 (* (* M M) -0.5))) t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * (n * n)));
double t_1 = cos(M) * exp((M * -M));
double tmp;
if (M <= -1.65e-9) {
tmp = t_1;
} else if (M <= -8.5e-209) {
tmp = t_0;
} else if (M <= 2.4e-222) {
tmp = exp(-l) * (M * (M * -0.5));
} else if (M <= 5000000000000.0) {
tmp = t_0 * (1.0 + ((M * M) * -0.5));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(((-0.25d0) * (n * n)))
t_1 = cos(m_1) * exp((m_1 * -m_1))
if (m_1 <= (-1.65d-9)) then
tmp = t_1
else if (m_1 <= (-8.5d-209)) then
tmp = t_0
else if (m_1 <= 2.4d-222) then
tmp = exp(-l) * (m_1 * (m_1 * (-0.5d0)))
else if (m_1 <= 5000000000000.0d0) then
tmp = t_0 * (1.0d0 + ((m_1 * m_1) * (-0.5d0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-0.25 * (n * n)));
double t_1 = Math.cos(M) * Math.exp((M * -M));
double tmp;
if (M <= -1.65e-9) {
tmp = t_1;
} else if (M <= -8.5e-209) {
tmp = t_0;
} else if (M <= 2.4e-222) {
tmp = Math.exp(-l) * (M * (M * -0.5));
} else if (M <= 5000000000000.0) {
tmp = t_0 * (1.0 + ((M * M) * -0.5));
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * (n * n))) t_1 = math.cos(M) * math.exp((M * -M)) tmp = 0 if M <= -1.65e-9: tmp = t_1 elif M <= -8.5e-209: tmp = t_0 elif M <= 2.4e-222: tmp = math.exp(-l) * (M * (M * -0.5)) elif M <= 5000000000000.0: tmp = t_0 * (1.0 + ((M * M) * -0.5)) else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * Float64(n * n))) t_1 = Float64(cos(M) * exp(Float64(M * Float64(-M)))) tmp = 0.0 if (M <= -1.65e-9) tmp = t_1; elseif (M <= -8.5e-209) tmp = t_0; elseif (M <= 2.4e-222) tmp = Float64(exp(Float64(-l)) * Float64(M * Float64(M * -0.5))); elseif (M <= 5000000000000.0) tmp = Float64(t_0 * Float64(1.0 + Float64(Float64(M * M) * -0.5))); else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (n * n))); t_1 = cos(M) * exp((M * -M)); tmp = 0.0; if (M <= -1.65e-9) tmp = t_1; elseif (M <= -8.5e-209) tmp = t_0; elseif (M <= 2.4e-222) tmp = exp(-l) * (M * (M * -0.5)); elseif (M <= 5000000000000.0) tmp = t_0 * (1.0 + ((M * M) * -0.5)); else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -1.65e-9], t$95$1, If[LessEqual[M, -8.5e-209], t$95$0, If[LessEqual[M, 2.4e-222], N[(N[Exp[(-l)], $MachinePrecision] * N[(M * N[(M * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 5000000000000.0], N[(t$95$0 * N[(1.0 + N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\
t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -1.65 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq -8.5 \cdot 10^{-209}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 2.4 \cdot 10^{-222}:\\
\;\;\;\;e^{-\ell} \cdot \left(M \cdot \left(M \cdot -0.5\right)\right)\\
\mathbf{elif}\;M \leq 5000000000000:\\
\;\;\;\;t\_0 \cdot \left(1 + \left(M \cdot M\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if M < -1.65000000000000009e-9 or 5e12 < M Initial program 79.5%
Simplified79.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 95.0%
mul-1-neg95.0%
unpow295.0%
distribute-rgt-neg-in95.0%
Simplified95.0%
if -1.65000000000000009e-9 < M < -8.5e-209Initial program 67.1%
Simplified67.1%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in n around inf 64.8%
unpow264.8%
Simplified64.8%
Taylor expanded in M around 0 64.8%
if -8.5e-209 < M < 2.39999999999999993e-222Initial program 77.0%
Simplified77.0%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in l around inf 35.6%
mul-1-neg35.6%
Simplified35.6%
Taylor expanded in M around 0 32.9%
associate-*r*32.9%
distribute-rgt1-in35.6%
+-commutative35.6%
*-commutative35.6%
unpow235.6%
Simplified35.6%
Taylor expanded in M around inf 82.2%
unpow282.2%
associate-*r*82.2%
*-commutative82.2%
associate-*r*82.2%
Simplified82.2%
if 2.39999999999999993e-222 < M < 5e12Initial program 75.0%
Simplified75.0%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
Simplified94.2%
Taylor expanded in n around inf 58.9%
unpow258.9%
Simplified58.9%
Taylor expanded in M around 0 58.9%
unpow258.9%
Simplified58.9%
Final simplification80.1%
(FPCore (K m n M l)
:precision binary64
(if (<= n 1e-207)
(* (cos M) (exp (* -0.25 (* m m))))
(if (<= n 8.5e-74)
(* (cos M) (exp (- l)))
(if (<= n 54.0) (* (cos M) (exp (* M (- M)))) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1e-207) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else if (n <= 8.5e-74) {
tmp = cos(M) * exp(-l);
} else if (n <= 54.0) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = exp((-0.25 * (n * 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 (n <= 1d-207) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else if (n <= 8.5d-74) then
tmp = cos(m_1) * exp(-l)
else if (n <= 54.0d0) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1e-207) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else if (n <= 8.5e-74) {
tmp = Math.cos(M) * Math.exp(-l);
} else if (n <= 54.0) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1e-207: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) elif n <= 8.5e-74: tmp = math.cos(M) * math.exp(-l) elif n <= 54.0: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1e-207) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (n <= 8.5e-74) tmp = Float64(cos(M) * exp(Float64(-l))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 1e-207) tmp = cos(M) * exp((-0.25 * (m * m))); elseif (n <= 8.5e-74) tmp = cos(M) * exp(-l); elseif (n <= 54.0) tmp = cos(M) * exp((M * -M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-207], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-74], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 10^{-207}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-74}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 9.99999999999999925e-208Initial program 75.3%
Simplified75.3%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in m around inf 58.0%
unpow258.0%
Simplified58.0%
if 9.99999999999999925e-208 < n < 8.50000000000000052e-74Initial program 90.1%
Simplified90.1%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Taylor expanded in l around inf 54.0%
mul-1-neg54.0%
Simplified54.0%
if 8.50000000000000052e-74 < n < 54Initial program 91.1%
Simplified91.1%
Taylor expanded in K around 0 91.1%
cos-neg91.1%
Simplified91.1%
Taylor expanded in M around inf 73.4%
mul-1-neg73.4%
unpow273.4%
distribute-rgt-neg-in73.4%
Simplified73.4%
if 54 < n Initial program 68.9%
Simplified68.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 97.3%
unpow297.3%
Simplified97.3%
Taylor expanded in M around 0 97.3%
Final simplification69.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -1.22e-28) (not (<= n 185.0))) (exp (* -0.25 (* n n))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -1.22e-28) || !(n <= 185.0)) {
tmp = exp((-0.25 * (n * n)));
} 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 ((n <= (-1.22d-28)) .or. (.not. (n <= 185.0d0))) then
tmp = exp(((-0.25d0) * (n * n)))
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 ((n <= -1.22e-28) || !(n <= 185.0)) {
tmp = Math.exp((-0.25 * (n * n)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -1.22e-28) or not (n <= 185.0): tmp = math.exp((-0.25 * (n * n))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -1.22e-28) || !(n <= 185.0)) tmp = exp(Float64(-0.25 * Float64(n * n))); 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 ((n <= -1.22e-28) || ~((n <= 185.0))) tmp = exp((-0.25 * (n * n))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -1.22e-28], N[Not[LessEqual[n, 185.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.22 \cdot 10^{-28} \lor \neg \left(n \leq 185\right):\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if n < -1.22e-28 or 185 < n Initial program 69.4%
Simplified69.4%
Taylor expanded in K around 0 98.0%
cos-neg98.0%
Simplified98.0%
Taylor expanded in n around inf 92.7%
unpow292.7%
Simplified92.7%
Taylor expanded in M around 0 92.7%
if -1.22e-28 < n < 185Initial program 84.6%
Simplified84.6%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 44.5%
mul-1-neg44.5%
Simplified44.5%
Final simplification72.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -1.22e-28) (not (<= n 185.0))) (exp (* -0.25 (* n n))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -1.22e-28) || !(n <= 185.0)) {
tmp = exp((-0.25 * (n * n)));
} 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 ((n <= (-1.22d-28)) .or. (.not. (n <= 185.0d0))) then
tmp = exp(((-0.25d0) * (n * n)))
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 ((n <= -1.22e-28) || !(n <= 185.0)) {
tmp = Math.exp((-0.25 * (n * n)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -1.22e-28) or not (n <= 185.0): tmp = math.exp((-0.25 * (n * n))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -1.22e-28) || !(n <= 185.0)) tmp = exp(Float64(-0.25 * Float64(n * n))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -1.22e-28) || ~((n <= 185.0))) tmp = exp((-0.25 * (n * n))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -1.22e-28], N[Not[LessEqual[n, 185.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.22 \cdot 10^{-28} \lor \neg \left(n \leq 185\right):\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if n < -1.22e-28 or 185 < n Initial program 69.4%
Simplified69.4%
Taylor expanded in K around 0 98.0%
cos-neg98.0%
Simplified98.0%
Taylor expanded in n around inf 92.7%
unpow292.7%
Simplified92.7%
Taylor expanded in M around 0 92.7%
if -1.22e-28 < n < 185Initial program 84.6%
Simplified84.6%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 44.5%
mul-1-neg44.5%
Simplified44.5%
Taylor expanded in M around 0 43.6%
Final simplification71.8%
(FPCore (K m n M l) :precision binary64 (if (<= l 1.02e-32) (* 0.5 (* K (* m (sin M)))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 1.02e-32) {
tmp = 0.5 * (K * (m * sin(M)));
} 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 (l <= 1.02d-32) then
tmp = 0.5d0 * (k * (m * sin(m_1)))
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 (l <= 1.02e-32) {
tmp = 0.5 * (K * (m * Math.sin(M)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 1.02e-32: tmp = 0.5 * (K * (m * math.sin(M))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 1.02e-32) tmp = Float64(0.5 * Float64(K * Float64(m * sin(M)))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 1.02e-32) tmp = 0.5 * (K * (m * sin(M))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 1.02e-32], N[(0.5 * N[(K * N[(m * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.02 \cdot 10^{-32}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(m \cdot \sin M\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 1.02000000000000002e-32Initial program 74.3%
Simplified74.3%
Taylor expanded in K around 0 81.3%
Taylor expanded in l around inf 12.2%
mul-1-neg12.0%
Simplified12.2%
Taylor expanded in m around inf 20.1%
associate-*r*20.1%
*-commutative20.1%
associate-*r*20.1%
rec-exp20.1%
associate-*r/20.1%
metadata-eval20.1%
distribute-rgt-neg-in20.1%
*-commutative20.1%
mul-1-neg20.1%
remove-double-neg20.1%
Simplified20.1%
Taylor expanded in l around 0 21.7%
associate-*r*21.7%
*-commutative21.7%
remove-double-neg21.7%
distribute-rgt-neg-out21.7%
distribute-rgt-neg-in21.7%
*-commutative21.7%
distribute-rgt-neg-out21.7%
distribute-rgt-neg-in21.7%
associate-*r*21.7%
distribute-lft-neg-in21.7%
metadata-eval21.7%
distribute-rgt-neg-out21.7%
distribute-rgt-neg-in21.7%
sin-neg21.7%
distribute-rgt-neg-in21.7%
remove-double-neg21.7%
Simplified21.7%
if 1.02000000000000002e-32 < l Initial program 79.8%
Simplified79.8%
Taylor expanded in K around 0 98.9%
cos-neg98.9%
Simplified98.9%
Taylor expanded in l around inf 92.3%
mul-1-neg92.3%
Simplified92.3%
Taylor expanded in M around 0 92.3%
(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 75.9%
Simplified75.9%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in l around inf 35.2%
mul-1-neg35.2%
Simplified35.2%
Taylor expanded in M around 0 34.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 75.9%
Simplified75.9%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in l around inf 35.2%
mul-1-neg35.2%
Simplified35.2%
Taylor expanded in l around 0 5.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 75.9%
Simplified75.9%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in l around inf 35.2%
mul-1-neg35.2%
Simplified35.2%
Taylor expanded in l around 0 5.6%
Taylor expanded in M around 0 5.6%
herbie shell --seed 2024097
(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)))))))