From 7fb8faf9e2ff880f7e3368e3f5a5fc9324102af0 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Sun, 8 Nov 2015 00:06:47 -0600 Subject: [PATCH] Fix MappingQ1 --- source/fe/mapping_q_generic.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index 9f5eec7b3d..4696483c38 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -106,8 +106,10 @@ namespace internal eta1 = -c/b; eta2 = -c/b; } - // special case #2: if c is very small: - else if (std::abs(c/b) < 1e-12) + // special case #2: if c is very small or the square root of the + // discriminant is nearly b. + else if (std::abs(c) < 1e-12*std::abs(b) + || std::abs(std::sqrt(discriminant) - b) <= 1e-14*std::abs(b)) { eta1 = (-b - std::sqrt(discriminant)) / (2*a); eta2 = (-b + std::sqrt(discriminant)) / (2*a); -- 2.39.5