From f87b4394d399fbf0ef3155a8d8cc4b5a75dd64b4 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Wed, 14 Aug 2013 23:48:01 -0700 Subject: [PATCH] Fix precision problem in interval::cos --- src/interval/interval_def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interval/interval_def.h b/src/interval/interval_def.h index b9e6cdbc6..9842d2418 100644 --- a/src/interval/interval_def.h +++ b/src/interval/interval_def.h @@ -1166,7 +1166,7 @@ template void interval::cos () { m_lower_open = m_upper_open = false; m_lower_inf = m_upper_inf = false; T const pi_twice = numeric_traits::pi_twice(); - fmod(pi_twice); + fmod(interval(numeric_traits::pi_twice_lower(), numeric_traits::pi_twice_upper())); if(m_upper - m_lower >= pi_twice) { // If the input width is bigger than 2pi, // it covers whole domain and gets [-1.0, 1.0] @@ -1178,7 +1178,7 @@ template void interval::cos () { if(m_lower >= numeric_traits::pi_upper()) { // If the input is bigger than pi, we handle it recursively by the fact: // cos(x) = -cos(x - pi) - *this -= numeric_traits::pi(); + *this -= interval(numeric_traits::pi_lower(), numeric_traits::pi_upper()); cos(); neg(); lean_assert(check_invariant());